如何解决如何使用 CSS 绘制在 Bootstrap Carousel 指示器中移动的内圆?
如何使用 CSS 绘制在 Bootstrap Carousel 指示器中移动的内圆?
如下所示:
悬停需要如下:
目前我写的代码如下:
<style lang="sass">
.carousel-indicators li
background-color: transparent
border: 0
border-radius: 100%
Box-shadow: 0 0 0 .2rem rgba(255,255,1)
height: 22px
margin-left: 15px
margin-right: 15px
width: 22px
.carousel-indicators li:hover
background-color: #fff
border: 0
border-radius: 100%
Box-shadow: 0 0 0 .2rem rgba(255,1)
height: 22px
margin-left: 15px
margin-right: 15px
width: 22px
</style>
解决方法
使用 pseudo-elements
这样做。
首先定位 li
,它也作为非活动状态:
.carousel-indicators li {
border-radius: 50%;
width: 6px;
height: 6px;
padding: 4px;
position: relative;
margin: 0 15px;
background-color: transparent;
opacity: 1;
}
现在创建 border
使用 pseudo-elements
:
.carousel-indicators li:after {
border-radius: 50%;
padding: 10px;
border: 4px solid #fff;
position: absolute;
content: "";
top: -7px;
left: -7px;
bottom: -7px;
right: -7px;
}
我们已将背景 transparent
分配给 li
,但我们希望背景 white
处于 active
状态,
.carousel-indicators li.active {
background-color: white;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。