在使元素大小动画时如何保持边界-Radius?

发布于 2025-01-22 09:06:24 字数 2284 浏览 0 评论 0原文

我希望轮播指示器动画就像列表项目弹出到零半径。
但是,在我尝试的情况下,列表项目以平方形的形状而不是圆形。有可能处于圆形形状吗?

$('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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

紫罗兰の梦幻 2025-01-29 09:06:24

我已经通过

$('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: radial-gradient(circle, #2E8B57 50%, transparent 51%);
  background-position: center;
  background-size: 0% 0%;
  background-repeat: no-repeat;
}

.carousel-indicators li.active {
  //background-color: #2E8B57;
  border-radius: 12px;
  background-image: radial-gradient(circle, #2E8B57 50%, transparent 91%);
  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 have managed to overcome this using radial-gradient from here

$('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: radial-gradient(circle, #2E8B57 50%, transparent 51%);
  background-position: center;
  background-size: 0% 0%;
  background-repeat: no-repeat;
}

.carousel-indicators li.active {
  //background-color: #2E8B57;
  border-radius: 12px;
  background-image: radial-gradient(circle, #2E8B57 50%, transparent 91%);
  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>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文