3-2编程练习
来源:3-2 编程练习
慕斯卡8226687
2019-09-08 15:54:40
<!--老师为什么当我把margin放到.one,.two,.three时三个div块之间就没有间隔呢?-->
<!DOCTYPE html>
<html>
<head>
<title>渐变</title>
<style type="text/css">
div{
height: 200px;
width: 400px;
margin-right: 20px;
display: inline-block;
}
.one{
height: 100px;
width: 100px;
background: -webkit-linear-gradient(orange,yellow);
background: -moz-linear-gradient(orange,yellow);
background: -o-linear-gradient(orange,yellow);
background: linear-gradient(orange,yellow);
float: right;
}
.two{
height: 100px;
width: 100px;
background: -webkit-linear-gradient(left,orange,yellow);
background: -moz-linear-gradient(right,orange,yellow);
background: -o-linear-gradient(right,orange,yellow);
background: linear-gradient(to right,orange,yellow);
float: right;
}
.three{
height: 100px;
width: 100px;
background: -webkit-linear-gradient(left top,orange,yellow);
background: -moz-linear-gradient(bottom right,orange,yellow);
background: -o-linear-gradient(bottom right,orange,yellow);
background: linear-gradient(to bottom right,orange,yellow);
float: right;
}
</style>
</head>
<body>
<div>
<div class="one"></div>
<div class="two"></div>
<div class="three"></div>
</div>
</body>
</html>
1回答
好帮手慕慕子
2019-09-08
同学你好, 首先,同学的代码效果实现的不错
另, 老师这边测试给。one和two、three三个元素设置margin-right值, 三个div之间是有间隔的
因为margin-right是元素距离右侧的距离,如果同学是给第一个元素one设置margin-right, 因为本来右侧就是空白, 所以看不到效果。 建议: 可以给中间的设置看看效果
如果帮助到了你, 欢迎采纳!
祝学习愉快~~~~
相似问题