html - div元素排列

标签 html css

谁能告诉我为什么#contHolder div 没有被推到第一行? 用“任何文本内容”替换表格元素,一切都正确对齐。

<div id="footerWrapper"style="display: block; width:100%;">
    <div id="firstCol" style="float:left; width: 30%;">
        <div id="footerProjectTitle" style="float: left; width: 100%; background-color:red;">title</div> 
        <div style="clear:both"></div>  
        <div id="contHolder"style="float: left; width: 30%; background-color: #ffc0cb;">
            <table>
            </table>
        </div>
    </div>
    <div id="secondCol" style="float:left; width: 30%;">
        <div id="linkHolder"style="float: left; width: 100%; background-color: #f0ffff;">
            <table>
            </table>
        </div>
    </div>
</div>

这是一个 fiddle

http://jsfiddle.net/KzJN3/

更新的 fiddle : http://jsfiddle.net/KzJN3/2/

谢谢!

最佳答案

问题出在这里:

<div class="noborder" style="clear: both; width: 100%; height: 0px; line-height: 0px; font-size: 0px;"> </div>

你告诉它 clear:both 所以这个元素之后的任何 float 都将在一个新行上开始。

float 是一个难题,请参阅:http://css-tricks.com/all-about-floats/获取有关它们及其工作原理的一些有用信息。

关于html - div元素排列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14990179/

相关文章:

jquery - 悬停时突出显示整行

javascript - 根据窗口大小将文本写入页面底部

javascript - html 未在 ng-repeat 中呈现

javascript - 将 onchange 和 onclick 绑定(bind)在一起 jQuery 不起作用

html - 在单独的列中水平对齐 div

html - 使DIV在中间垂直对齐

html - 在非引导页面中将填充添加到 100% 宽度的 div

javascript - 在 Jquery UL li 过滤器中更改链接颜色

jQuery:进度条内的中心文本

css - 限制表格宽度