css - div 向左浮动....当它包装时,它包装了所有时髦的东西

标签 css html

我有 1 到 10 个 float div。如果我显示 1-5 或全部 10,它们显示正常:

item1 item2 item3 item4 item5

item6 item7 item8 item9 item10

但如果我展示其中的 7 个,它们就会开始变得怪异:

item1 item2 item3 item4 item5

                     item6

元素7

我该如何解决这个问题?这是 div 代码的样子:

<div style="float:left; margin-right:4px; margin-top:5px; text-align:center; padding:7px; color:#0066a4; font-size: smaller; width:100px;">
  <a href="#" onclick="getElectronicServiceCopy('10'); return false;"><img src="/images/images/Icons/Vehicle_Green.png" border="0"></a>
  <br>Vehicle
</div>

谢谢大家!

最佳答案

如果我看到你的代码,你可能必须为你的 floated DIV 定义 height

例如:

div{
 height:200px;
}

关于css - div 向左浮动....当它包装时,它包装了所有时髦的东西,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9844887/

相关文章:

css - 带有 Bootstrap 4 的多行导航栏,品牌形象在导航上方居中

php - HTML/CSS : Image Not being displayed

jquery - 点击事件不会在内部 div 上触发

css - 如何摆脱 PNG 不可见边框?

jquery - 从最后一个列表项中删除 'border-right'

javascript - 单击更改 map 大小

html - 寻找更好的方法来设置可调整大小的背景 Css3/HTML/mootools

html - 当我将鼠标悬停在导航栏上时,我不知道如何阻止它突出显示我的事件链接

css - 防止 ionic 中的第一个输入焦点

css - react /HTML5 : How to avoid details tag from being wrapped to next row after openning it?