css - 如何使用 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, 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, 255, 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;
}
代码笔: https ://codepen.io/manaskhandelwal1/pen/abmRbZv
推荐阅读
- python - 执行 Python 代码时自动打开浏览器
- c# - 有没有办法在 .NET Core 的 CorsPolicy 上使用“AllowAnyOrigin”属性?
- javascript - 有条件地将数据从封闭视图传递到部分视图
- angular - 角 6 货币格式,不带 INR 符号的小数点
- excel - 在 PowerQuery/Excel 中管理文件夹刷新
- python - 散景服务器开发模式缺少文件
- sqlite - 我将带有 UTC 日期的行插入到数据库中的 int 列中。如何仅获取过去 24 小时内插入的行?
- javascript - 我应该如何区分引导响应导航栏中的下拉菜单
- node.js - Socket.io:连接到 Heroku 上的套接字服务器时找不到 404
- windows - 如何压缩文件名中包含今天日期的文件夹?