使用CSS实现奥运五环,包括环与环的嵌套
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.circle{ //第一层圆
width: 200px;
height: 200px;
border: 10px solid #000;
border-radius: 50%;
position: absolute;
}
.circle:after{ //第二层圆
content: "";
/*display: block;*/
width: 200px;
height: 200px;
border-radius: 50%; //设置成圆形
border: 10px solid blue;
position: absolute;
top: -10px;
left: -10px;
}
.blue{
border-color: blue;
}
.blue::after{
border: 10px solid blue;
z-index: 1; //向上浮动
border-bottom-color: transparent;
}
.black{
left: 240px;
}
.black::after{
border: 10px solid black;
z-index: 1;
border-left-color: transparent;
/*border-right-color: transparent;*/
}
.red{
left: 470px;
border-color: red;
}
.red::after{
border: 10px solid red;
z-index: 1;
border-left-color: transparent;
}
.yellow{
left: 120px;
top: 120px;
border-color: yellow;
}
.yellow::after{
border: 10px solid yellow;
}
.green{
left: 350px;
top: 120px;
border-color: green;
}
.green::after{
border: 10px solid green;
z-index: 1;
border-top-color: transparent;//设置顶边框透明
border-right-color: transparent;
}
</style>
</head>
<body>
<div class="circle blue"></div>
<div class="circle black"></div>
<div class="circle red"></div>
<div class="circle yellow"></div>
<div class="circle green"></div>
</body>
</html>