list-style
我们最常用的是消除 ul li 的样式
在 reset.css 里面使用 list-style: none 的童鞋请举爪~
但是 list-style 不止有 none。
list-style 是由以下三个属性组合的简写属性。
list-style-typelist-style-imagelist-style-position
每个属性都可单独设置,也可以直接设置在 list-style 上。下面分别介绍这三个属性。
listStyleType
- css_tricks
- js_tricks
- blog
详细代码
vue
<script setup>
import { ref } from 'vue'
import { ElRadioGroup, ElRadio, ElText } from 'element-plus'
const type = ref([
{
name: "disc",
isTest: false,
comment: "实心圆点 (默认值)"
},
{
name: "circle",
isTest: false,
comment: "空心圆点"
},
{
name: "square",
isTest: false,
comment: "实心方块"
},
{
name: "decimal",
isTest: false,
comment: "十进制阿拉伯数字"
},
{
name: "cjk-decimal",
isTest: true,
comment: "中日韩十进制数"
},
{
name: "decimal-leading-zero",
isTest: false,
comment: "十进数"
},
{
name: "lower-roman",
isTest: false,
comment: "小写罗马数字"
},
{
name: "upper-roman",
isTest: false,
comment: "大写罗马数字"
},
{
name: "lower-greek",
isTest: false,
comment: "小写希腊数字"
},
{
name: "lower-alpha",
isTest: false,
comment: "小写 ASCII"
},
{
name: "lower-latin",
isTest: false,
comment: "小写 ASCII(IE7 以下不支持)"
},
{
name: "upper-alpha",
isTest: false,
comment: "大写 ASCII"
},
{
name: "upper-latin",
isTest: false,
comment: "大写 ASCII(IE7 以下不支持)"
},
{
name: "armenian",
isTest: false,
comment: "传统美式数字"
},
{
name: "georgian",
isTest: false,
comment: "传统英式数字"
},
{
name: "hebrew",
isTest: true,
comment: "传统希伯来数字"
},
{
name: "ethiopic-numeric ",
isTest: true,
comment: "埃塞俄比亚数字"
},
{
name: "hiragana",
isTest: true,
comment: "平假名数字(日语)"
},
{
name: "katakana",
isTest: true,
comment: "片假名数字(日语)"
},
{
name: "hiragana-iroha",
isTest: true,
comment: "旧式平假名数字(日语)"
},
{
name: "katakana-iroha",
isTest: true,
comment: "旧式平假名数字(日语)"
},
{
name: "japanese-informal",
isTest: true,
comment: "日语非正式数字"
},
{
name: "japanese-formal",
isTest: true,
comment: "日语数字 "
},
{
name: "korean-hangul-formal",
isTest: true,
comment: "韩文数字"
},
{
name: "korean-hanja-informal",
isTest: true,
comment: "韩式数字"
},
{
name: "korean-hanja-formal",
isTest: true,
comment: "韩式数字(繁体)"
},
{
name: "simp-chinese-informal",
isTest: true,
comment: "中文数字"
},
{
name: "cjk-ideographic",
isTest: true,
comment: "中文数字"
},
{
name: "simp-chinese-formal",
isTest: true,
comment: "大写繁体中文数字"
},
{
name: "trad-chinese-informal",
isTest: true,
comment: "繁体中文数字"
},
{
name: "trad-chinese-formal",
isTest: true,
comment: "大写繁体中文数字"
}
]);
const selectedType = ref("disc");
const template = ref([
"css_tricks",
"js_tricks",
"blog"
])
</script>
<template>
<div class="list-type-container">
<ul class="list-container" :style="{ listStyleType: selectedType }">
<li v-for="(item, index) in template" :key="index">
{{ item }}
</li>
</ul>
<el-text class="mx-1" type="primary" size="large">list-style-type: {{ selectedType }}</el-text>
<br>
<el-radio-group v-model="selectedType" class="type-container">
<el-radio v-for="item in type" :key="item.name" :value="item.name">
{{ item.name }} - {{ item.comment }}
</el-radio>
</el-radio-group>
</div>
</template>
<style scoped lang="scss">
.list-container {
li {
width: 40%;
margin: 0;
}
}
.mx-1 {
text-align: center;
}
.type-container {
display: flex;
justify-content: space-between;
align-content: flex-start;
flex-wrap: wrap;
label {
width: 50%;
margin: 0;
padding: 10px 0;
}
}
</style>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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
listStylePosition
- 赵客缦胡缨,吴钩霜雪明。
- 银鞍照白马,飒沓如流星。
- 十步杀一人,千里不留行。
- 事了拂衣去,深藏身与名。
- 闲过信陵饮,脱剑膝前横。
- 将炙啖朱亥,持觞劝侯嬴。
- 三杯吐然诺,五岳倒为轻。
- 眼花耳热后,意气素霓生。
- 救赵挥金槌,邯郸先震惊。
- 千秋二壮士,烜赫大梁城。
- 纵死侠骨香,不惭世上英。
- 谁能书阁下,白首太玄经。
详细代码
vue
<script setup>
import { ref } from 'vue'
import { ElText, ElRadioGroup, ElRadio } from 'element-plus'
const selectedType = ref("inside");
const position = ref(["inside", "outside"]);
</script>
<template>
<div>
<ul :style="{ listStylePosition: selectedType }">
<li>赵客缦胡缨,吴钩霜雪明。</li>
<li>银鞍照白马,飒沓如流星。</li>
<li>十步杀一人,千里不留行。</li>
<li>事了拂衣去,深藏身与名。</li>
<li>闲过信陵饮,脱剑膝前横。</li>
<li>将炙啖朱亥,持觞劝侯嬴。</li>
<li>三杯吐然诺,五岳倒为轻。</li>
<li>眼花耳热后,意气素霓生。</li>
<li>救赵挥金槌,邯郸先震惊。</li>
<li>千秋二壮士,烜赫大梁城。</li>
<li>纵死侠骨香,不惭世上英。</li>
<li>谁能书阁下,白首太玄经。</li>
</ul>
<el-text type="text" size="large">list-style-position: {{ selectedType }}</el-text>
<br> <br>
<el-radio-group v-model="selectedType">
<el-radio v-for="item in position" :key="item" :value="item">
{{ item }}
</el-radio>
</el-radio-group>
</div>
</template>
<style scoped lang="scss">
li {
margin: 0 auto;
width: 50%;
background: rgba(0, 173, 181, 0.5);
}
</style>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
40
41
42
43
44
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
40
41
42
43
44
listStyleImage
注意
list-style-image 没有设置图片大小的属性。
- 楼阴缺,栏杆影卧东厢月
- 东厢月,一天风霜,杏花如雪
详细代码
vue
<script setup>
import { ElRadio, ElRadioGroup, ElText } from 'element-plus';
import { computed, ref } from 'vue';
const radioSelect = ref("/gitee.svg")
const listStyleImage = computed(() => {
return {
"list-style-image": "url(" + radioSelect.value + ")"
}
})
</script>
<template>
<ul :style="listStyleImage">
<li>楼阴缺,栏杆影卧东厢月 </li>
<li> 东厢月,一天风霜,杏花如雪 </li>
</ul>
<el-text type="text" size="large">list-style-image: {{ radioSelect }}</el-text>
<br>
<br>
<el-radio-group v-model="radioSelect">
<el-radio value="/gitee.svg">
/gitee.svg
<img src="/gitee.svg" style="height: 20px;width: 20px;">
</el-radio>
<el-radio value="/mainView/logo.svg">
/mainView/logo.svg
<img src="/mainView/logo.svg" style="height: 20px;width: 20px;">
</el-radio>
</el-radio-group>
</template>
<style lang="scss" scoped>
li::marker {
width: 20px !important;
height: 20px !important;
}
</style>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
40
41
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
40
41
demo不太好搞