我试图这样做,当页面加载圆圈出现,这是好的,但我需要它们向外生长,从中心到小到大,而不是从左上角:
你可以看到我目前在这里:http://thomasbritton.co.uk/projects/ebrd/
理想情况下,希望这可以在CSS中完成,但如果它更容易/更稳定,可以使用JS.
有任何想法吗?
这是动画部分我的css:
.circle a { border-radius: 150px; color: #fff; height: 0; position: absolute; text-decoration: none; width: 0; } .circle a.grow { -webkit-animation-name: grow; -webkit-animation-duration: 2.2s; -webkit-animation-timing-function: ease; -webkit-animation-iteration-count: 1; -webkit-animation-direction: normal; -webkit-animation-delay: 0; -webkit-animation-play-state: running; -webkit-animation-fill-mode: forwards; -moz-animation-name: grow; -moz-animation-duration: 2.2s; -moz-animation-timing-function: ease; -moz-animation-iteration-count: 1; -moz-animation-direction: normal; -moz-animation-delay: 0; -moz-animation-play-state: running; -moz-animation-fill-mode: forwards; animation-name: grow; animation-duration: 2.2s; animation-timing-function: ease; animation-iteration-count: 1; animation-direction: normal; animation-delay: 0; animation-play-state: running; animation-fill-mode: forwards; } @-webkit-keyframes grow { 0% { -moz-transform: scale(0); } 100% { -moz-transform: scale(1); } } @-moz-keyframes grow { 0% { -moz-transform: scale(0); } 100% { -moz-transform: scale(1); height: 168px; width: 168px; } } @keyframes grow { 0% { -moz-transform: scale(0); } 100% { -moz-transform: scale(1); } }
解决方法
这是你需要做的一个粗略的例子:
jsfiddle.net/UxtJV/.它使用一些JS来添加一个类来为圆圈设置动画.它的宽度,高度,顶部和左侧属性都是动画的,给定位置:相对.
div.circle { position: relative; width: 0px; height: 0px; top: 50px; left: 50px; -webkit-transition-duration: 2s; -webkit-transition-property: all; -webkit-transition-timing-function: ease-in-out; text-align: center; background: red; color: white; border-radius: 100%; padding: 20px; overflow: hidden; } div.circle.open { top: 0px; left: 0px; width: 100px; height: 100px; }