CSS - dispaly:inline-block

如果不是 块级( block ) 类型的元素,当设置 width, height, margin 属性时不起作用。因为 display 为 inline 时,没有这些属性。


但是,如果 display 设置为 : inline-block 的元素,即保持了 inline 的自调节位置,又同时具备了 block 的 width, height, margin 属性。


========================================================================

[url=http://www.w3schools.com/css/css_inline-block.asp][b]CSS Layout - inline-block[/b][/url]

[b]The inline-block Value[/b]

It has been possible for a long time to create a grid of boxes that fills the browser width and wraps nicely (when the browser is resized), by using the [color=brown]float[/color] property.

However, the [color=brown]inline-block[/color] value of the [color=brown]display[/color] property makes this even easier.

[color=brown]inline-block[/color] elements are like [color=brown]inline[/color] elements but they can have a [color=brown]width[/color] and a [color=brown]height[/color].



<!DOCTYPE html>
<html>
<head>
<style>
.floating-box {
display: inline-block;
margin: 10px;
border: 3px solid #73AD21;

height:50px;
}
</style>
</head>
<body>

<h2>The New Way - using inline-block</h2>

<!-- same effect with :
<span> element. -->
<span class="floating-box">Floating box</span>Hello, World!
<span class="floating-box">Floating box</span>Hello, World!
<span class="floating-box">Floating box</span>Hello, World!
<span class="floating-box">Floating box</span> Hello, World!

<!-- use <div> element -->
<div class="floating-box">Floating box</div>
<div class="floating-box">Floating box</div>
<div class="floating-box">Floating box</div>
<div class="floating-box">Floating box</div>


</body>
</html>




[img]http://dl2.iteye.com/upload/attachment/0116/9034/e9ed1dcb-52d2-3aa2-a702-8d9802733b5e.png[/img]


-
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值