麻烦老师帮忙看看怎么优化,谢谢
来源:3-2 编程练习
YoLo_H
2020-07-14 13:12:38
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.div1,.div2,.div3{
width: 200px;
height: 200px;
border: 1px solid black;
}
div:nth-child(n)
{
float: left;
margin: 0 10px;
text-align: center;
padding-bottom: 20px;
}
.div1
{
background:-webkit-linear-gradient(red,yellow);
background: -moz-linear-gradient(red,yellow);
background: -o-linear-gradient(red,yellow);
background: linear-gradient(red,yellow);
}
.div2
{
background:-webkit-linear-gradient(left,red,yellow);
background: -moz-linear-gradient(right,red,yellow);
background: -o-linear-gradient(right,red,yellow);
background: linear-gradient(to right,red,yellow);
}
.div3
{
background:-webkit-linear-gradient(left top,red,yellow);
background: -moz-linear-gradient(right bottom,red,yellow);
background: -o-linear-gradient(right bottom,red,yellow);
background: linear-gradient(to right bottom,red,yellow);
}
</style>
</head>
<body>
<div>
<h4>上下方向减变</h4>
<div class="div1"></div>
</div>
<div>
<h4>左右方向渐变</h4>
<div class="div2"></div>
</div>
<div>
<h4>对角方向渐变</h4>
<div class="div3"></div>
</div>
</body>
</html>
1回答
同学你好,从代码中看,知识点掌握了。不过效果不太符合效果图,颜色写反了,建议优化:
如果我的回答帮到了你,欢迎采纳,祝学习愉快~
相似问题