[英]Animate Pseudo CSS elements - any framework?
我正在創建具有偽css元素(:: before,:: after)的條形圖。
當我看到條形看起來不錯時,我找不到動畫高度變化的好方法。 當我使用動畫功能時,偽元素消失,並且僅在動畫完成時出現。 其他人對如何實現這一目標有想法嗎? 還有其他動畫框架也可以渲染偽元素嗎?
CodePen: http ://codepen.io/anon/pen/OyGamW
的HTML
<ul><li><div class="fill bar1">100%</div></li></ul>
CSS:
*{
padding:0;
margin: 0;
}
body {
height: 100%;
background-repeat: no-repeat;
background-attachment: fixed;
background:#cdcdcf;
overflow: hidden;
}
ul {
list-style-type:none;
overflow:hidden;
padding-left:10px;
padding-top:40px;
}
li{
float:left;
height:800px;
margin-top: 30px;
}
.fill {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
width: 90px;
line-height: 90px;
position: relative;
height: 300px;
top: 161px;
padding: 0px 0px 0px 8px;
left: 70px;
border: none;
font: normal normal bold 26px/normal Tahoma, Geneva, sans-serif;
color: rgba(255,255,255,1);
text-align: left;
-o-text-overflow: clip;
text-overflow: clip;
background: -webkit-linear-gradient(0deg, rgba(255,43,43,1) 0, rgba(209,31,31,1) 100%);
background: -moz-linear-gradient(90deg, rgba(255,43,43,1) 0, rgba(209,31,31,1) 100%);
background: linear-gradient(90deg, rgba(255,43,43,1) 0, rgba(209,31,31,1) 100%);
background-position: 50% 50%;
-webkit-background-origin: padding-box;
background-origin: padding-box;
-webkit-background-clip: border-box;
background-clip: border-box;
-webkit-background-size: auto auto;
background-size: auto auto;
-webkit-transform: scaleX(1) scaleY(1) scaleZ(1) skewY(-3deg);
transform: scaleX(1) scaleY(1) scaleZ(1) skewY(-3deg);
-webkit-transform-origin: 0 0 0;
transform-origin: 0 0 0;
-webkit-box-shadow: 0 11px 18px -5px #841313 inset;
box-shadow: 0 11px 18px -5px #841313 inset;
}
.fill::before {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
width: 50%;
height: 100%;
position: absolute;
content: "";
top: 0;
left: 0;
border: none;
font: normal normal normal 16px/normal "Times New Roman", Times, serif;
color: rgba(0, 0, 0, 0.901961);
-o-text-overflow: clip;
text-overflow: clip;
background: -webkit-linear-gradient(-180deg, #c62121 0, rgba(132,19,19,1) 100%);
background: -moz-linear-gradient(270deg, #c62121 0, rgba(132,19,19,1) 100%);
background: linear-gradient(270deg, #c62121 0, rgba(132,19,19,1) 100%);
background-position: 50% 50%;
-webkit-background-origin: padding-box;
background-origin: padding-box;
-webkit-background-clip: border-box;
background-clip: border-box;
-webkit-background-size: auto auto;
background-size: auto auto;
text-shadow: none;
-webkit-transform: scaleX(1) scaleY(1) scaleZ(1) translateX(-44px) skewY(20deg);
transform: scaleX(1) scaleY(1) scaleZ(1) translateX(-44px) skewY(20deg);
-webkit-transform-origin: 100% 100% 0;
transform-origin: 100% 100% 0;
-webkit-box-shadow: 0 11px 18px -5px #841313 inset;
box-shadow: 0 11px 18px -5px #841313 inset;
}
.fill::after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
width: 100%;
height: 16.1px;
position: absolute;
content: "";
top: -1px;
left: 0;
border: none;
font: normal normal normal 16px/normal "Times New Roman", Times, serif;
color: rgba(0, 0, 0, 0.901961);
-o-text-overflow: clip;
text-overflow: clip;
background: rgba(132,19,19,1);
text-shadow: none;
-webkit-transform: scaleX(1) scaleY(1) scaleZ(1) translateX(-50%) translateY(-91%) skewX(70.5deg);
transform: scaleX(1) scaleY(1) scaleZ(1) translateX(-50%) translateY(-91%) skewX(70.5deg);
-webkit-transform-origin: 0 0 0;
transform-origin: 0 0 0;
}
JS:
$(document).ready(function() {
setInterval(function() {
doAnimation();
},4000);
doAnimation();
});
function doAnimation() {
$('.fill').animate({ "height": "150px", "top": "311px"}, 1000);
$('.fill').delay(1000).animate({ "height": "300px", "top": "161px"}, 1000);
}
謝謝
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.