html - 制作流畅的动画条纹div

标签 html css

我在制作流畅的动画条纹 div 时遇到了麻烦,比如进度条。

CSS:

.animationStripes{
  width: 300px;
  height: 50px;
  background-image: repeating-linear-gradient(-45deg, rgb(0, 0, 0), rgb(0, 0, 0) 25px, blue 25px, blue 50px);
  -webkit-animation:progress 2s linear infinite;
  -moz-animation:progress 2s linear infinite;
  -ms-animation:progress 2s linear infinite;
  animation:progress 2s linear infinite;
}
@keyframes progress{
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: -70px 0px;
  }
} 

http://plnkr.co/edit/4wPv1ogKNMfJ6rQPhZdJ?p=preview

问题是背景图像渐变的最右边有一个奇怪的错位。我该如何修复这种错位?

最佳答案

你见过this tutorial吗?关于 CSS 技巧?

@import url(https://fonts.googleapis.com/css?family=Ropa+Sans);
body {
  padding: 20px;
  font-family: 'Ropa Sans', sans-serif;
}

.product {
  width: 376px;
  padding: 15px;
  position: relative;
  float: left;
  margin: 0 20px 0 0;
}

.product>img {
  display: block;
  position: relative;
}

.product:hover .product-hover,
.product:active .product-hover {
  opacity: 1;
}

.product-hover {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0;
  transition: opacity 0.3s ease;
  background-size: 30px 30px;
  background-image: linear-gradient(45deg, rgba(0, 0, 0, 0.1) 25%, transparent 25%, transparent 50%, rgba(0, 0, 0, 0.1) 50%, rgba(0, 0, 0, 0.1) 75%, transparent 75%, transparent);
  animation: barberpole 0.5s linear infinite;
}

@keyframes barberpole {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 60px 30px;
  }
}

.product-info {
  position: absolute;
  bottom: 30px;
  right: 30px;
  background: white;
  width: 150px;
  padding: 10px 10px 50px 10px;
}

.subhead {
  color: #f00;
  text-transform: uppercase;
  font-weight: bold;
}

.product-name {
  color: #990033;
  text-transform: uppercase;
  font-weight: bold;
  margin: 0;
  letter-spacing: -1px;
}

.price {
  position: absolute;
  bottom: 10px;
  right: 10px;
}

.amount {
  color: red;
  font-size: 150%;
}

.amount>span {
  font-size: 75%;
}

h1 {
  font-size: 72px;
  margin: 2px 0 0 0;
}

VIEW SCSS CODE
<div class="product">
  <div class="product-hover"></div> <img src="http://fillmurray.com/300/300" />
  <div class="product-info">
    <div class="subhead">Sale</div>
    <h2 class="product-name">Fleece</h2>
    <p class="product-description">Beat the chill and get cozy.</p>
    <div class="price"> <span class="from">from</span> <span class="amount">        <span>$</span>9.90 </span>
    </div>
  </div>
</div>

关于html - 制作流畅的动画条纹div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31546894/

相关文章:

html - 对齐文本中心未按预期工作

javascript - 为什么这个 JQuery 'keyup' 函数没有填充 div?

javascript - jQuery addclass 和 removeclass 按顺序从子到父和反向

html - “选择”表单元素破坏了我网站的响应式布局

所有列表项的 Javascript/JQuery 相同下拉菜单

html - 根据另一个 div 的高度设置一个 div 的最小高度

javascript - .fadeToggle 更改我的 div 的位置

javascript - 将数据作为 JSON 对象存储在 Firebase 中

javascript - 如何允许用户使用样式自定义文本字段

css - 如何设置 CSS 网格列的宽度和最大宽度?