红绿灯效果
使用HTML+CSS实现如图所示的红绿灯效果。
从图中我们可以知道有三个不同颜色的圆,并且三个圆都在灰色矩阵之中
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.parent {
width: 200px;
height: 600px;
margin: 0 auto;
background-color: gray;
padding: 25px;
}
.one,.two,.three {
width: 150px;
height: 150px;
border-radius: 50%;
}
.one {
background-color: red;
}
.two {
background-color: green;
margin-top: 50px;
/* 50px为上下两个圆的边距 */
}
.three {
background-color: yellow;
margin-top: 50px;
}
</style>
<div class="parent">
<div class="one"></div>
<div class="two"></div>
<div class="three"></div>
</div>
横向布局
基于 flex 布局来实现横向布局
实现效果如图所示:
图中布局分为四个小部分,我们可以使用flex布局来实现
<style>
* {
margin: 0;
padding:0;
box-sizing: border-box;
}
.parent {
background-color: gray;
}
.nav {
background-color: red;
color: white;
text