【问题标题】:Pulsing dot in CSS Chrome display issueCSS Chrome显示问题中的脉冲点
【发布时间】:2014-01-19 10:54:31
【问题描述】:

我正在尝试使用 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 中显示正常,但在 Chrome 中,应该脉冲的圆形边框被严重像素化。该边框是pulse span 内的空范围。

我看了将近一个小时,找不到问题所在。

【问题讨论】:

  • 你为什么不把你所有的代码放在 www.jsfiddle.net 上?
  • 您最好更改尺寸属性(宽度和高度)而不是使用scale。因为scale 只会拉伸图像并且不会计算/生成新像素,因为尺寸调整会生成新像素。 jsFiddle 不完美,但就是这样

标签: css google-chrome keyframe css-animations webkit-transition


【解决方案1】:

没有“text-indent: -9000px”,效果会好一些。

Fiddle.

.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);
}

【讨论】:

  • 是的,它看起来好一点。但是为什么它在 Firefox 中可以正常工作,而在 Chrome 中却有问题呢?是否有可能它继承了一些 CSS 位,这弄乱了脉冲部分?关于继承的属性,我应该寻找什么?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-03-07
  • 1970-01-01
  • 1970-01-01
  • 2012-11-28
  • 2021-11-07
  • 1970-01-01
相关资源
最近更新 更多