css盒子模型设置的缩略形式

CSS简写技巧
本文介绍了CSS中常用的简写技巧,包括padding和margin属性的多种简写形式,以及border属性的灵活设置方法。这些技巧能够帮助开发者更高效地编写样式代码。

css里面的盒子模型里面设置padding,margin的上下或者左右的大小有很多方式,下面说说两种不同的方式:
original method:

padding-top:0px
padding-right:20px
padding-bottom:30px
padding-left:10px

new method:

padding:0px 20px 30px 10px
// top right bottom left respectively

同理:

margin-top:0px
margin-right:20px
margin-bottom:30px
margin-left:10px
margin:0px 20px 30px 10px

如果上下左右的值都是一样的话,那我们可以这样设置:
the old method:

padding-top:20px
padding-right:20px
padding-bottom:20px
padding-left:20px

the new method:

padding:20px

如果上下值和左右值分别一样呢:
the old method:

margin-top:0px
margin-right:20px
margin-bottom:0px
margin-left:20px

the new method

margin:0px 20px
// top and bottom right and left respectively

border的属性设置:
the old method

border-width:thin
border-style:solid
boder-color black

the new method:

border:thin solid black
//width style color respectively

border的属性设置更加灵活多变:

boder:solid thin black
border:blcak solid thin
border:solid
boder:blcak solid

还有很多其他的简写方式,我就不一一阐述了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值