html - 如何制作响应式png序列?

标签 html css

我正在尝试制作响应式 png 序列。

我试过的代码在这里。代码有什么问题?
1. 如果我删除了 background-size :100%;它显示图像直到并且除非它不可见。
2. react 迟钝。 (如果我评论背景大小:100%) CSS

 .eye {
      position: relative;
      width: 70%;
      margin: -10% auto 0 auto; /* positioning tweak */
    }
    .pngseq{
      position: absolute;
      left: 0;
      right: 0;
      top: 0;
      bottom: 0;
      background:  url('http://arnoculus.com/img/eye-sprite.png') no-repeat 0 0%;
      background-size: 100%;
      animation: play 3s steps(58) infinite;
    }
@-webkit-keyframes play {
    from { background-position:    0px; }
     to { background-position: -30740px; }
}

@-moz-keyframes play {
     from { background-position:    0px; }
     to { background-position: -30740px; }
}

@-ms-keyframes play {
     from { background-position:    0px; }
     to { background-position: -30740px; }
}

@-o-keyframes play {
     from { background-position:    0px; }
     to { background-position: -30740px; }
}

@keyframes play {
     from { background-position:    0px; }
     to { background-position: -30740px; }
}

HTML

<div class="eye">
      <div class="pngseq">
      </div>
</div>

JSFIDDLE

最佳答案

你有几个错误...

这是你的代码工作

.eye {
    position: relative;
    width: 70%;
    height: 800px;
    background-color: red;
    margin: -10% auto 0 auto; /* positioning tweak */
}
 
.pngseq{
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    background:  url('http://arnoculus.com/img/eye-sprite.png') no-repeat 0 0%;
    background-size: 5800%;
    animation: play 3s steps(57) infinite; 
}

@keyframes play {
    from { background-position:    0px 0px; }
    to { background-position: 100% 0px; }
}
<div class="eye">
    
    <div class="pngseq">
        
    </div>
    
</div>

它有点晃动,可能是原始图像不准确,或者在此尺寸下使用百分比可能有一些舍入误差;我不确定。

关于html - 如何制作响应式png序列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30816560/

相关文章:

css - <img> 和 <p> 文本在同一行,并且 <p> 相同高度

html - CSS/HTML 导航菜单中的 Safari 中不显示下拉部分

css - 使用 :not to exclude selectors

javascript - 使用 onchange 时如何将 JavaScript 函数结果传递到 html?

javascript - 如何创建内容平滑过渡

javascript - 如何在不提交表单的情况下将 enter 键转换为 tab 键

css - 关于段落前后加横线的问题

html - 框阴影在页面截断处截断

python - Tornado - 为什么没有 StaticFileHandler 的静态文件不起作用?

php - domPDF - 如果达到页面高度,表格总是会底部