css input type 浮点类型_应用浮点时的css显示属性

当元素被浮动时,display属性如何影响布局?主要对比了display:block, inline和inline-block三种情况,并讨论了IE等旧版浏览器可能存在的差异。设置float:left或right会覆盖display属性,强制元素表现得像块级元素,宽度行为则因display属性不同而有所区别。
摘要由CSDN通过智能技术生成

When an element is floated, how do different display properties affect the layout? Or, what are the differences, if any, between these classes:

div.foo {

display: block;

float: left;

}

div.foo2 {

display: inline;

float: left;

}

div.foo3 {

display: inline-block;

float: left;

}

EDIT:

If there are no differences according to the spec, then do certain antiquated versions of browsers (ahem, IE) render them differently?

解决方案

If I read the spec correctly, and practice confirms this, setting float: left or right overrides the display property anyway and forces display: block on the element (although with peculiarities, see below), so there will no difference between your three examples:

left

The element generates a block box that is floated to the left. Content flows on the right side of the box, starting at the top (subject to the 'clear' property).

right

Similar to 'left', except the box is floated to the right, and content flows on the left side of the box, starting at the top.

none

The box is not floated.

Differently from normal display: block though, setting float dictates its own behaviour in regards to width that override the display property: if no width was explicitly specified, the floated element will take up as much width as it needs, as opposed to standard block element behaviour of taking up 100% width automatically.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值