在我的页面上 http://s361608839.websitehome.co.uk/pt-build/templatebuild/index.html如果你向下滚动是一个叫做定价的部分。右下方是一个名为 priceBlock 的 div。
我目前正在使用此 css 将其 float 到右侧,但不知何故 div 被推到下一行。
#priceBlock {
width: 206px;
height: 303px;
background: url(../images/pricing-bg.jpg) no-repeat;
float: right;
clear: both;
}
div 在#pricing 中并且 div 中有足够的空间来容纳它而不会转到另一行。
我需要对我的 css 进行哪些更改才能使其向右浮动但位于#pricing 中#leftcol 内的内容旁边?
谢谢
最佳答案
您的#priceblock 规则正在清除 float ,有效地消除了#pricing 左侧 float 所需的效果。您可以通过删除 clear both 属性或指定 clear:right:
来修复此行为#priceBlock {
width: 206px;
height: 303px;
background: url(../images/pricing-bg.jpg) no-repeat;
float: right;
clear: right; /*clear: both;*/
overflow: hidden;
}
关于css - 如何正确添加 float 属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7687576/