0

我试图让一些嵌套的 div 标签根据其中的内容自动增长高度。这里给出了一个示例代码。例如,中间有更多内容,但高度似乎没有增长。让它自动增长的诀窍是什么?我从父母内部取出所有浮动元素,认为这可能是CSS 明确规则。但这也无济于事。感谢任何帮助。

 <div id="editmain">
        <div class="ticker">
         some content here
        </div>
        <div class="ticker">
         some longer content content here
        </div>
       <div class="ticker">
         some content here
        </div>
    </div>

    #editmain
        {
            position:relative;
            min-height:480px;
            background-color:#84d;
            overflow:hidden;
            padding: 20px 0px 30px 0px;  
        }

.ticker
        {    
            position:relative;
            border-bottom: solid 2px #ddd;
            margin:10px;
            background-color:white;
            overflow:hidden;             
            height:auto;
            min-height:100px;
        }
4

1 回答 1

0

在绝对定位模型中,一个盒子完全从正常流程中移除(它对后面的兄弟姐妹没有影响)并分配一个相对于包含块的位置。

w3.org

删除绝对定位并找到另一种使用宽度和边距格式化标签和输入的方法。小提琴

   .tickertxtlabel
    {
        display:inline-block;
        margin: 10px 10px 10px 10px;        
        width:90px; 
    }
于 2013-02-22T17:37:02.200 回答