定义显示方式
background-repeat:用来定义图像的显示方式
repeat-x:背景图像在横向上平铺
repeat-y:背景图像在纵向上平铺
repeat:背景图像在横向和纵向上平铺
no-repeat:背景图像不平铺
round:背景图像自动缩放知道适应填满整个容器
space:背景图像以相同的间距平铺且填满整个容器或某个方向
background-repeat:repeat-x;
定义显示位置
background-position:定义背景图像的位置,他又两个值可以是
left,top,bottom,right或者百分数,或者带单位的数值
当他有一个值时:将会被解释为水平位置,垂直位置默认为center
当他有两个值时:第一值为水平位置,第二值为垂直位置
background-position:left top /*左上角*/
定义固定背景
background-attachment:用来定义固定背景,不会随着网页的移动而移动。他的值有:
fixed:背景图像相对于浏览器窗体固定
scroll:背景图像相对于元素固定
local:背景图像相对于元素内容固定,当元素内容滚动时背景图像也会光着滚动。
background-attachment:fixed;
实战:设计图文新闻内容
<meta charset="utf-8">
<title>越南政坛“地震”、富商被判重刑,发生了什么</title>
<link rel="stylesheet" href="index.css" />
</head>
<body>
<div class="top"><h1>越南政坛“地震”、富商被判重刑,发生了什么</h1>
<div class="top_1"><span>2024年04月30日 17:19</span> <a href="https://www.yicai.com/news/102093294.html">一财网</a></div>
<img src="w700d1q75cms.jpg" alt="" />
<p>·····</p></div><!--此处省略若干字,如需要可下载源码-->
<div class="bottom"><p>责任编辑:刘光博</p></div>
</body>
</html>
*{
margin: 5px;
padding: 0;
}
a{
text-decoration: none;
color: #000;
}
p{
text-indent:2em;
}
img{
width: 500px;
height: 300px;
}
.top .top_1 span{
color: #88888C;
}
.top .top_1 a:hover{
color: red;
}
.top img{
float: left;
}
.bottom{
position:absolute;
right: 15px;
}
复习
float浮动,left左浮动,right右浮动
positon定位,absolute绝对定位,right,left,top,bootom调整定位位置
text-decoration文本装饰 , none:去除文本装饰 underline下划线 overline上划线
text-indent定义缩进
新学
em:一个相对单位长度,用于定义元素的尺寸、间距等属性,相对于前对象文本内的尺寸。2em相当于是前对象文本尺寸的两倍。例:一个元素字体尺寸是16px,2em相当于是32px。