我正在尝试使用CSS创建脉冲点效果。
HTML标记很简单:
<span class="map-pin pulse dark">
<span></span>
</span>
CSS就像这样:
@-webkit-keyframes pulse{
0%{
opacity:1;
width: 16px;
height: 16px;
}
50% {
opacity:.5;
-webkit-transform: scale(3);
}
100%{
opacity: 0;
}
}
@-moz-keyframes pulse{
0%{
opacity:1;
width: 16px;
height: 16px;
}
50% {
opacity:.5;
-moz-transform: scale(3);
}
100%{
opacity: 0;
}
}
.pulse{
width: 32px;
height: 32px;
background: none;
display: inline-block;
position: relative;
vertical-align: middle;
line-height: 16px;
text-align: center;
}
.pulse>*{
position: relative;
border:1px solid #fa565a;
width: 16px;
height: 16px;
display: inline-block;
vertical-align: middle;
text-indent: -9000px;
-webkit-border-radius:30px;
-moz-border-radius:30px;
border-radius:30px;
-webkit-transition-property:top, bottom, left, right, opacity, border-width;
-webkit-animation-duration:2s;
-webkit-animation-name:pulse;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: cubic-bezier(0,0,0,1);
-moz-transition-property:top, bottom, left, right, opacity, border-width;
-moz-animation-duration:2s;
-moz-animation-name:pulse;
-moz-animation-iteration-count: infinite;
-moz-animation-timing-function: cubic-bezier(0,0,0,1);
}
.pulse.dark>*{
border-color: #fa565a;
}
.pulse:after{
content: '';
display: block;
position:absolute;
width: 16px;
height: 16px;
left: 8px;
top: 2px;
-webkit-border-radius:10px;
-moz-border-radius:10px;
border-radius:10px;
background: #2B6882;
vertical-align: middle;
}
.pulse.dark:after{
background: #fa565a;
-webkit-box-shadow: none;
-moz-box-shadow: none;
}
它在firefox中显示OK,但在Chrome中,应该是脉冲的圆形边框是高度像素化的。该边框是pulse
范围内的空跨度。
我正在看它差不多一个小时,找不到可能出现的问题。
答案 0 :(得分:2)
没有“text-indent:-9000px”,它的效果稍好一些。
.pulse>*{
position: relative;
border:1px solid #fa565a;
width: 16px;
height: 16px;
display: inline-block;
vertical-align: middle;
-webkit-border-radius:30px;
-moz-border-radius:30px;
border-radius:30px;
-webkit-transition-property:top, bottom, left, right, opacity, border-width;
-webkit-animation-duration:2s;
-webkit-animation-name:pulse;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: cubic-bezier(0,0,0,1);
-moz-transition-property:top, bottom, left, right, opacity, border-width;
-moz-animation-duration:2s;
-moz-animation-name:pulse;
-moz-animation-iteration-count: infinite;
-moz-animation-timing-function: cubic-bezier(0,0,0,1);
}