代码之家  ›  专栏  ›  技术社区  ›  Moon

CSS Div:如果Div位于底部,则对齐sde中的所有内容

  •  0
  • Moon  · 技术社区  · 14 年前

    我正试图建立这个图表。。。这就是问题所在

    TAKE A LOOK AT THIS .. 我要把这些div“绿色”与底部对齐

    5 回复  |  直到 14 年前
        1
  •  2
  •   alex    14 年前

    How is this?

    display: inline-block

    我换了你的 float: left display: inline-block 默认情况下 vertical-align: baseline 我相信。

    Check out how to do one for IE6 and IE7.

    另外,作为旁注,您应该指定 id 属性到一个元素 . 否则使用类。

        2
  •  2
  •   Sebastian Patane Masuelli    14 年前

    干得好: http://jsfiddle.net/SebastianPataneMasuelli/uYghh/16/

    更改 left 移动它们的价值。

    编辑:更新了示例以获得正确的页边距。

        3
  •  1
  •   jspeshu    14 年前

    请将绿色div的id属性更改为彼此不同的内容
    http://jsfiddle.net/uYghh/33/

        4
  •  0
  •   Michael    14 年前

    删除 float:left; 使用 display:inline-block;

        5
  •  0
  •   Jogendra    14 年前

    更改你的css

    #green
    {
        position: relative;
        float : left;
        width  : 20px;
        top:100%;
        margin : 5px;
        border: solid 1px #0fb551;
        background: -webkit-gradient(linear, 0 0, 0 bottom, from(#0fb551), to(#064d23));
        background: -moz-linear-gradient(#0fb551, #064d23);
        background: linear-gradient(#0fb551, #064d23);   
        -pie-background: linear-gradient(#0fb551, #064d23);
        behavior: url(pie.htc);    
    }
    
    Add some jQuery to your project
    
    $(function(){
        $('#graph div').each(function(){
            var ht=$(this).height();
            $(this).css({'margin-top':-ht-4+'px'});
    
        });
    });