问题:绘制如下图所示的关闭按钮
思路:
1.用一个div作为按钮的容器;
2.使用伪元素before和after各绘制一条线;
- 设置伪元素的宽度和高度;都使用绝对定位,水平居中,垂直居中;before伪元素顺时针旋转45度;after伪元素逆时针旋转45度
代码:
<!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>
.box {
position: relative;
height: 100px;
width: 100px;
background-color: #2ecc71;
}
.close {
font-size: 0;
}
.close::before,
.close::after {
content: '';
width: 50px;
height: 5px;