CSS 背景与列表

CSS 背景样式

- background-color    设置元素的背景颜色

- background-image   把图像设置为背景

- background-position   设置背景图像的起始位置

- background-attachment   背景图像是否固定或者随着页面的其余部分滚动

- background-repeat     设置背景图片是否重复以及如何重复

- background                 简写属性,作用是将背景属性设置在一个声明中


CSS列表样式

+ list-style-type    设置列表项标志的类型

+ list-style-image    将图像设置为列表项标志

+ list-style-position     设置列表中列表项标志的位置

+ list-style       简写属性,将列表属性设置在一个声明中


(1) 设置元素的背景颜色

background-color: 颜色|transparent

transparent是全透明黑色


	<style type="text/css">
			div{background-color: pink;
				width: 300px;
				padding: 10px;/*内边框*/
				margin: 10px;/*外边框*/
				border: 20px solid;/*边框*/
			}
	</style>


(2)设置元素的背景图片

 background-image:url | none

元素的背景占据了元素的全部尺寸,包括内边距与边框,不包括外边距

默认地,背景图像位于元素的左上角,并在水平与垂直方向上重复

			div.pic2{
				width: 500px;
				height: 500px;
				background-image: url("1.jpg");
			}
当背景图片和背景颜色都设置时,背景图片会覆盖背景颜色。

(3)背景图片重复

background-repeat: repeat | no-repeat | repeat-x | repeat-y

			div.pic2{
				width: 500px;
				height: 500px;
				background-image: url("1.jpg");
				background-repeat: no-repeat;
				border: 1px solid #ff0000;/*边框为1px,实线,颜色为红色*/
			}
(4)背景图片的显示方式

background-attachment: scroll | fixed

scroll:默认值,背景图片随滚动条滚动

fixed: 当页面的其余部分滚动时,背景图片不会移动

(5)背景图片定位

设置元素的背景图片的起始位置

background-position: 百分比 | 值 | top | right | bottom | left | center

			div.pic2{
				width: 800px;
				height: 800px;
				background-image: url("1.jpg");
				background-repeat: no-repeat;
				border: 1px solid #ff0000;/*边框为1px,实线,颜色为红色*/
				/*background-attachment: fixed;*/
				background-position: 10% 10%;
			}

(6)背景缩写


----------------------------------------------------------------------------------------------------

CSS 列表样式

(1)设置列表项的标记样式类型

list-style-type: 关键字 | none


	<style type="text/css">
		ul li{list-style-type: circle;}
		ol li{list-style-type: upper-roman;}
	</style>
(2) 列表项标记

使用图片设置列表项的标记

list-style-image: url | none

(3)列表项标记位置

设置列表项标记的位置

list-style-position: inside | outside

inside:列表项目标记放置在文本以内,且环绕文本根据标记对齐

outside:默认值,列表项目录标记放置在文本以外,且环绕文本不根据标记对齐

(4)列表样式缩写

list-style: xxx ;


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值