文字两端对齐

1
2
3
4
5
.name {
display: inline-block;
text-align: justify;
text-align-last: justify;
}

关闭按钮

效果图

html

1
2
3
<span class="icon">
<i class="el-icon-close"/>
</span>

css

1
2
3
4
5
6
7
8
9
10
11
12
13
.icon {
width: 50px;
height: 50px;
background: #FF9D47;
box-shadow: 0px 2px 10px 0px rgba(201, 181, 169, 0.5);
border-radius: 0px 0px 0px 86px;
margin-left: auto;
color: #fff;
font-size: 22px;
}
.icon i{
margin: 10px 0px 0px 20px;
}

鼠标hover样式和active激活样式相同

1
2
3
4
5
6
7
8
9
10
<div class="list">
<div class="item active">
<img src="1.png">
<span>测试文本</span>
</div>
<div class="item active">
<img src="2.png">
<span>测试文本2</span>
</div>
</div>

less语法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
.list {    
.item {
background: #F5F5F5;
border-radius: 20px;
padding: 8px 10px;
font-size: 14px;
color: #303133;
display: flex;
align-items: center;
cursor: pointer;
img {
width: 24px;
height: 24px;
margin-right: 4px;
}
&:hover {
background: #FFF7E7;
color: #DD5107;
}
&:nth-child(1) {
&:hover, &.active {
background: #FFF7E7;
color: #DD5107;
img {
content: url('1-hover.png');
}
}
}
&:nth-child(2) {
&:hover, &.active {
background: #FFF7E7;
color: #DD5107;
img {
content: url('2-hover.png');
}
}
}
}
}