css 列表的设置,css设置列表样式的实现方法

css设置列表样式的实现方法

发布时间:2020-08-31 11:09:23

来源:亿速云

阅读:131

作者:小新

小编给大家分享一下css设置列表样式的实现方法,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!

list-style属性

list-style属性是一个速记属性,它可以设置与列表相关的三个不同属性值:ul {

list-style: || || ;

}

这是一个语法示例:ul {

list-style: square outside none;

}

相当于:ul {

list-style-type: square;

list-style-position: outside;

list-style-image: none;

}

在简写中,如果省略任何值,它们将恢复到其初始状态。

list-style-type属性

list-style-type属性通过在列表中设置每个标记或项目符号的内容来定义列表的类型。可接受的关键字值list-style-type包括:

disc,circle,square,decimal,decimal-leading-zero,lower-roman,upper-roman,lower-greek,lower-latin,upper-latin,armenian,georgian,lower-alpha,upper-alpha,none

在CSS3中引入了非关键字值,但是对于它们来说,浏览器可以支持的还是很少。

我们来看看每个关键字值的效果:

fdaafa184d3277e7f1475b523d7665ed.png

list-style-type属性适用于所有列表以及设置为的任何元素display: list-item。

列表标记的颜色将是元素的设置颜色(通过color属性设置)。

list-style-position属性

list-style-position属性定义列表标记的位置,并接受以下两个值之一:“inside”或“outside”。下面我们来看看它们的效果,从列表中删除了填充,并添加了左侧红色边框:

1ea95daa0f5beb27baebfa43d1155398.png

list-style-image属性

list-style-image属性确定列表标记是否使用图像设置,并接受值“none”或指向图像的URL:ul {

list-style-image: url(images/bullet.png);

}

我们来看看设置list-style-image属性后的列表效果:

119832d3b830ac1e73e45fef494e3154.png

浏览器支持

85256697c3b18b7a0c94bf203b14f9a4.png

IE6 / 7不支持所有关键字值,list-style-type属性还有一个错误,浮动列表项是不会显示其列表标记。可以通过list-style-image在列表项上使用背景图像来解决此问题。

看完了这篇文章,相信你对css设置列表样式的实现方法有了一定的了解,想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在Vue的单文件组件中,可以通过使用v-bind指令将CSS值与动态组件状态关联起来。你可以使用字符串、对象、CSS模块和自定义注入名称来实现动态的CSS样式使用字符串方式,你可以在template中定义一个class,然后在style标签中使用v-bind绑定动态的颜色值。例如: ```html <template> <div :class="cssStyle">css-style</div> </template> <script> import { ref } from 'vue'; const colorRed = ref("red"); </script> <style lang="less" scoped> .css-style { color: v-bind(colorRed); } </style> ``` 使用对象方式,你可以在template中定义一个class,然后在style标签中使用v-bind绑定一个对象的颜色属性。例如: ```html <template> <div :class="cssStyle">css-style</div> </template> <script> import { ref } from 'vue'; const obj = ref({ color: "red" }); </script> <style lang="less" scoped> .css-style { color: v-bind('obj.color'); } </style> ``` 使用CSS模块方式,你可以在style标签中使用module属性,并将生成的CSS类作为$style对象的键暴露给组件。例如: ```html <template> <div :class="$style.red">$style.red</div> </template> <style module> .red { color: red; } </style> ``` 使用自定义注入名称,你可以在style标签的module属性中定义一个自定义的名称,然后在class中使用该名称。例如: ```html <template> <div :class="[zxx.red, zxx.border">$style.red</div> </template> <style module="zxx"> .red { color: red; } .border { border: 1px solid #000; } </style> ``` 最后,你还可以在template中使用数组形式来指定动态的CSS样式。例如: ```html <div :style="[baseStyles, overridingStyles"></div> <div :style="[{color:(index == 1 ? conFontColor:'#000')},{fontSize:'18px'}"></div> ``` 以上是关于在Vue中如何使用CSS动态样式的几种方式。希望对你有所帮助!<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [css Style、动态样式](https://blog.csdn.net/weixin_45137240/article/details/131042283)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *3* [动态样式绑定--style 和 class](https://blog.csdn.net/lzfengquan/article/details/125521472)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值