为什么我的background-size和background-position会失效呢?

来源:3-2 编程练习

慕容3241023

2019-06-09 11:48:36

<!DOCTYPE html>

<html>

<head lang="en">

<meta charset="UTF-8">

<title>线性渐变</title>

<style type="text/css">

/*此处写代码*/

*{margin:0;padding:0;}

section > div{

width:200px;height:300px;padding-right:90px; float:left;

background-size:200px 200px;

background-position: bottom;

}

div:first-child{

background:linear-gradient(yellow,red) content-box;

}

div:nth-child(2){background: linear-gradient(to right,yellow,red) content-box}

div:last-child{background: linear-gradient(to left top,yellow,red) content-box}

</style>

</head>

<body>

<!--此处写代码-->

<section>

<div>

上下方向渐变

</div>

<div>

左右方向渐变

</div>

<div>

对角方向渐变

</div>

</section>

</html>



写回答

1回答

樱桃小胖子

2019-06-09

background-position用来设置背景图片相对容器原点的起始位置

background-size用来设置背景图的尺寸

这里不是设置的背景图片,因此会失效

祝学习愉快!


0

0 学习 · 40143 问题

查看课程