【发布时间】:2014-04-21 23:18:41
【问题描述】:
我正在尝试创建一个简单的 html/css 图表,它必须为大于 0 的值和小于 0 的值分隔条形。 它看起来像这样:http://jsfiddle.net/km27Q/3/ 而且我坚持将顶部 div 的垂直对齐居中到底部。所以我需要类 bar 的 div 与类 graph_top 的 div 中的底部垂直对齐有人可以帮我吗? 我找了几个教程,但找不到任何可以使用百分比作为宽度值的东西。
图片说明: http://s21.postimg.org/wnjcvjism/Screenshot_from_2014_04_21_16_26_01.jpg
代码如下:
HTML
<div class="graph">
<div class="graph_top">
<div class="lol">
<div class="bar" style="height: 1px;"></div><div class="bar" style="height: 11px;"></div>
</div>
</div>
<div class="horizontal_line"></div>
<div class="graph_bottom">
<div class="bar2" style="height: 1px;"></div><div class="bar2" style="height: 11px;"></div>
</div>
</div>
CSS
.graph {
width: 95%;
height: 101px;
border: 1px solid #aeaeae;
background-color: #eaeaea;
}
.graph_top
{
width: 100%;
height: 50px;
max-height: 50px;
position: relative;
}
.graph_bottom
{
width: 100%;
height: 50px;
max-height: 50px;
}
.horizontal_line
{
width: 100%;
border-bottom: 1px solid #aeaeae;
height: 1px;
padding: 0px;
}
.bar
{
width: 10%;
background-color: #aeaeae;
float: left;
}
.bar2
{
width: 10%;
background-color: maroon;
float: left;
}
.lol
{
width: 100%;
position:absolute;
bottom:0;
}
感谢您的回答。
【问题讨论】:
-
请明智地澄清您的问题点......
-
我编辑了描述,希望它更容易理解
-
垂直对齐抱歉
标签: css html vertical-alignment