image是否有disabled属性_8、背景属性

背景属性

常用属性

属性值解释background-colorred背景颜色background-imageurl(“”)背景图片background-repeatrepeat;no-repeat;repeat-x;repeat-y图像平铺;不平铺;按x轴平铺;按y轴平铺background-positionunset;left;right;center;top;bottom;20px背景定位、对齐方式,靠上层边框的位置,如果只写一个值,其他值值默认居中background-attachmentfixed;scroll背景浮动,如果页面元素过多有上下拉条就这个参数就可以定义是否跟随拉条一起浮动background-sizelength/percentage/cover/containlength:设置背景图像的高度和宽度,第一个值设置宽度,第二个值设置高度,如果只设置一个值,则第二个值会被设置为 “auto”。

percentage:以父元素的百分比来设置背景图像的宽度和高度,第一个值设置宽度,第二个值设置高度,如果只设置一个值,则第二个值会被设置为 “auto”。

cover:把背景图像扩展至足够大,以使背景图像完全覆盖背景区域,背景图像的某些部分也许无法显示在背景定位区域中。

contain:把图像图像扩展至最大尺寸,以使其宽度和高度完全适应内容区域。

background-color

div {

height: 200px;

background-color: darkgray;

}

edd8851bf4f200efe6150148a63f2213.png

background-image

content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">

Document

div {

height: 300px;

background-image: url("http://fc.topitme.com/c/46/4b/11204201334c04b46cl.jpg");

}

6ca1542c5b2974af736a0db8af93d3df.png

background-repeat

content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">

Document

div {

height: 300px;

background-color: darkgray;

background-image: url("http://fc.topitme.com/c/46/4b/11204201334c04b46cl.jpg");

background-repeat: no-repeat;

}

c422fe0d7631e46344f4c7aea7b76799.png

background-position

content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">

Document

div {

height: 300px;

background-color: darkgray;

background-image: url("http://fc.topitme.com/c/46/4b/11204201334c04b46cl.jpg");

background-repeat: no-repeat;

background-position: center;

}

39f9d2c321b3cf36c58551993283e456.png

background-attachment

content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">

Document

div {

background-color: darkgray;

background-image: url("http://fc.topitme.com/c/46/4b/11204201334c04b46cl.jpg");

background-repeat: no-repeat;

background-position: center;

background-attachment: fixed;

}

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

北京马哥教育

d271808c984c4feccf2dfc5000b95dce.gif

对齐案例

content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">

Document

a {

display: inline-block;

width: 67px;

height: 32px;

background-image: url("110.png");

}

a:hover {

background-image: url("110.png");

background-position: bottom;

}

9f71277d4cce05e7944dc72899529ffe.gif
  • 注意:background-image作为背景图片,可以超过div盒子的大小,background-position只是一个对齐方式,如果设置background-position为top,那么图标的上边框将和盒子的上边框对齐,如果为botton那么图标的底边框将和盒子的底边框对齐,超过部分忽略不计。

五彩导航

content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">

Document

div {

height: 50px;

text-align: center;

font-size: 0px;

}

a {

display: inline-block;

width: 120px;

height: 58px;

line-height: 50px;

text-decoration: none;

color: crimson;

font-size: 16px;

}

.a1 {

background-image: url("bg1.png");

}

.a1:hover {

background-image: url("bg2.png");

}

.a2 {

background-image: url("bg3.png");

}

.a2:hover {

background-image: url("bg4.png");

}

.a3 {

background-image: url("bg5.png");

}

.a3:hover {

background-image: url("bg6.png");

}

.a4 {

background-image: url("bg7.png");

}

.a4:hover {

background-image: url("bg2.png");

}

五彩导航

五彩导航

五彩导航

五彩导航

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值