在使元素大小动画时如何保持边界-Radius?
我希望轮播指示器动画就像列表项目弹出到零半径。
但是,在我尝试的情况下,列表项目以平方形的形状而不是圆形。有可能处于圆形形状吗?
$('li').click(function(sender) {
$('.active').removeClass('active');
$(this).addClass('active');
})
.carousel-indicators li {
width: 12px;
border-radius: 12px;
border-color: #2E8B57 !important;
height: 24px;
border-width: 1pt;
margin: 1px 3px 1px 3px;
padding: 1px;
transition: opacity 0.6s ease, background-size 1s ease;
background-image: linear-gradient(#2E8B57, #2E8B57);
background-position: center;
background-size: 0% 0%;
background-repeat: no-repeat;
}
.carousel-indicators li.active {
//background-color: #2E8B57;
border-radius: 12px;
background-image: linear-gradient(#2E8B57, #2E8B57);
background-size: 100% 100%;
background-clip: content-box, padding-box;
padding: 1px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="icon" type="image/x-icon" href="../../assets/images/favicon.ico">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" type="text/css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
I want carousel indicators animation to be like the list item pops out to zero radius.
However, in my attempt, the list item animates in a square shape rather than in a circular shape. Is it possible to get in a circular shape?
$('li').click(function(sender) {
$('.active').removeClass('active');
$(this).addClass('active');
})
.carousel-indicators li {
width: 12px;
border-radius: 12px;
border-color: #2E8B57 !important;
height: 24px;
border-width: 1pt;
margin: 1px 3px 1px 3px;
padding: 1px;
transition: opacity 0.6s ease, background-size 1s ease;
background-image: linear-gradient(#2E8B57, #2E8B57);
background-position: center;
background-size: 0% 0%;
background-repeat: no-repeat;
}
.carousel-indicators li.active {
//background-color: #2E8B57;
border-radius: 12px;
background-image: linear-gradient(#2E8B57, #2E8B57);
background-size: 100% 100%;
background-clip: content-box, padding-box;
padding: 1px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="icon" type="image/x-icon" href="../../assets/images/favicon.ico">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" type="text/css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经通过
I have managed to overcome this using radial-gradient from here