2

是否可以仅使用 css 在下面的链接中创建类似于 iphone 上闪亮效果的渐变?
http://prntscr.com/22oa4f

我试过使用下面的代码,但它不是“闪亮的”

background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(255, 255, 255, .15)), to(rgba(0, 0, 0, .25))), -webkit-gradient(linear, left top, right bottom, color-stop(0, rgba(255, 255, 255, 0)), color-stop(0.5, rgba(255, 255, 255, .1)), color-stop(0.501, rgba(255, 255, 255, 0)), color-stop(1, rgba(255, 255, 255, 0)));
background-image: -moz-linear-gradient(top, rgba(255, 255, 255, .15), rgba(0, 0, 0, .25)), -moz-linear-gradient(left top, rgba(255, 255, 255, 0), rgba(255, 255, 255, .1) 50%, rgba(255, 255, 255, 0) 50%, rgba(255, 255, 255, 0));
background-image: linear-gradient(top, rgba(255, 255, 255, .15), rgba(0, 0, 0, .25)), linear-gradient(left top, rgba(255, 255, 255, 0), rgba(255, 255, 255, .1) 50%, rgba(255, 255, 255, 0) 50%, rgba(255, 255, 255, 0));

我在这个 jsfiddle -> http://jsfiddle.net/3qWYL/中创建了一个容器

4

6 回答 6

7

检查这个,这是你要找的。jsFiddle 演示

HTML

<div class="d shine"></div>

CSS

.d {
    width: 300px;
    height: 500px;
    background: #111;
}
.shine:before {
    content:"";
    position:absolute;
    width: 300px;
    height: 500px;
    background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(255, 255, 255, .15)), to(rgba(0, 0, 0, .25))), -webkit-gradient(linear, left top, right bottom, color-stop(0, rgba(255, 255, 255, 0)), color-stop(0.5, rgba(255, 255, 255, .1)), color-stop(0.501, rgba(255, 255, 255, 0)), color-stop(1, rgba(255, 255, 255, 0)));
    background: -moz-linear-gradient(top, rgba(255, 255, 255, .15), rgba(0, 0, 0, .25)), -moz-linear-gradient(left top, rgba(255, 255, 255, 0), rgba(255, 255, 255, .1) 50%, rgba(255, 255, 255, 0) 50%, rgba(255, 255, 255, 0));
    background: linear-gradient(top, rgba(255, 255, 255, .15), rgba(0, 0, 0, .25)), linear-gradient(left top, rgba(255, 255, 255, 0), rgba(255, 255, 255, .1) 50%, rgba(255, 255, 255, 0) 50%, rgba(255, 255, 255, 0));
}
于 2013-11-08T06:24:51.337 回答
7

.btn {
    position: relative;
    width: 150px;
    text-align: center;
    padding: .61538462em 1em;
    cursor: pointer;
    vertical-align: middle;
    color: #FFF;
    border: 1px solid #07c;
    border-radius: 2px;
    background-color: #0095ff;
    box-shadow: inset 0 1px 0 #66bfff;
}
.shiny::after {
    content: '';
    display: block;
    width: 70%;
    background: rgba(255, 255, 255, 0.2);
    background: linear-gradient(0deg, rgba(255, 255, 255, 0.2)50%, rgba(255, 255, 255, 0.7)100%); /* Safari 5.1-6.0 */
    background: -o-linear-gradient(0deg, rgba(255, 255, 255, 0.2)50%, rgba(255, 255, 255, 0.7)100%); /* Opera 11.1-12.0 */ 
    background: -moz-linear-gradient(0deg, rgba(255, 255, 255, 0.2)50%, rgba(255, 255, 255, 0.7)100%); /* Firefox 3.6-15 */
    background: linear-gradient(0deg, rgba(255, 255, 255, 0.2)50%, rgba(255, 255, 255, 0.7)100%); /* Standard syntax */

    left: -100%;
    top: 0;
    height: 100%;
    position: absolute;
    transition: none;
    -webkit-transition: none;
    -moz-transition: none;
    -o-transition: none;
    -ms-transition: none;
    -ms-transform: skewX(-20deg); /* IE 9 */
    -webkit-transform: skewX(-20deg); /* Safari */
    transform: skewX(-20deg);
}

.shiny:hover::after {
    left: 150%;
    transition: all 1s;
    -webkit-transition: all 1s;
    -moz-transition: all 1s;
    -o-transition: all 1s;
    -ms-transition: all 1s;
}
<div class="btn shiny">Hover Me</div>

于 2017-06-18T08:33:43.790 回答
1
.background {
background-image: linear-gradient(right, #111 11%, #333 56%);
background-image: -o-linear-gradient(right, #111 11%, #333 56%);
background-image: -moz-linear-gradient(right, #111 11%, #333 56%);
background-image: -webkit-linear-gradient(right, #111 11%, #333 56%);
background-image: -ms-linear-gradient(right, #111 11%, #333 56%);
background-image: gradient(right, #111 11%, #333 56%);
}
于 2015-05-01T21:01:49.717 回答
1

试试这个

background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#aebcbf), color-stop(50%,#6e7774), color-stop(51%,#0a0e0a), color-stop(100%,#0a0809));
于 2013-11-08T06:11:06.670 回答
0

我发现这个简单的子元素 + SCSS 对是最好看的:

HTML [类 || 班级名称]:

<div class={`full-indicator`}>
  <div class={`indicator-shine`}></div>
</div>

SCSS:

.full-indicator {
      transition: 0.25s ease-in-out;
      width: 0px;
      height: 0px;
      position: absolute;
      width: 25px;
      height: 25px;
      background-color: #ff5050;
      border-radius: 50%;
      box-shadow: 0px 0px 5px 0px rgba(0, 0, 0, 0.95);
      z-index: 2;
      
      .indicator-shine {
        width: 5px;
        height: 5px;
        position: absolute;
        background-color: rgba(255, 255, 255, 0.25);
        box-shadow: 0px 0px 5px 0px rgba(255, 255, 255, 0.75);
        border-radius: 50%;
        top: 15%;
        right: 25%;
      }
    }

这是为“完整状态指示器”制作的,可根据自己的需要自定义左/右和上/下、大小和颜色。

希望这对某人有用!

于 2020-09-13T17:01:11.177 回答
0

检查此代码

HTML

<div class="shiny"></div>

CSS

.shiny {
  width: 100%;
  height: 50px;
  background-color: #E6E9EA;
  overflow: hidden;
 }

.shiny::before{
 display: block;
 content: '';
 width: 50%;
 height:100%;
 transform: translate(50%);
 background-image: linear-gradient(to right, transparent, white, transparent);
 animation-name: shining;
 animation-duration: 3s;
 animation-iteration-count: infinite; 
}

@keyframes shining {
from {
 transform: translate(-50%);
}
to {
 transform: translate(100%);
}

}

于 2019-04-09T20:56:47.873 回答