盒子阴影开关过渡?

时间:2017-04-02 07:37:48

标签: html css css-transitions css-transforms box-shadow

http://lucasdebelder.be/googledoodle/ 这是一个实时版本。

因此,你可以在门户网站上看到它周围有一个发光,box-shadow;我希望它能够开启和关闭所以它有点感觉更真实,我添加了transition: box-shadow ease-in-out;但是它只在开始时,页面加载后才开始,然后继续发光。

这是相关代码。 (portaal_links表示左侧门户,rechts表示正确,它是荷兰语)

HTML:

<div class="portaal portaal_links"></div>
<div class="portaal portaal_rechts"></div>

CSS:

/*portaal general*/
.portaal {
    position: absolute;
    width: 100px;
    height: 200px;
    border-radius: 50px / 100px;
    bottom: 315px;
}



/*portaal left*/
.portaal_links {
    background: radial-gradient(ellipse at center, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
    transition: box-shadow ease-in-out;
    transition-delay: 1s;
    transition-duration: 1s;
    box-shadow: 0 0 55px #57B6FF;
    opacity: 0.75;
    left: 50px;
}


.portaal_rechts {
    background: radial-gradient(ellipse at center, rgba(243,197,189,1) 0%,rgba(232,108,87,1) 50%,rgba(234,40,3,1) 51%,rgba(255,102,0,1) 75%,rgba(199,34,0,1) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
    box-shadow: 0 0 55px #FF6600;
    opacity: 0.55;
    left: 750px;
}

2 个答案:

答案 0 :(得分:1)

使用动画而不是过渡。

关键帧:https://www.w3schools.com/cssref/css3_pr_animation-keyframes.asp

动画:https://www.w3schools.com/css/css3_animations.asp

&#13;
&#13;
.test {
  background: red;
  border-radius: 50%;
  width: 100px;
  height: 200px;
  animation: testing 3s linear infinite; }

@keyframes testing {
  25% { 
    box-shadow: 0 0 55px rgba(0,0,0,0.9); }
  75% {
    box-shadow: 0 0 0 transparent; }
}
&#13;
<div class="test"></div>
&#13;
&#13;
&#13;

答案 1 :(得分:1)

您可以在JSONObject

上创建如下所示的animation

box-shadow
/*portaal general*/
.portaal {
    position: absolute;
    width: 100px;
    height: 200px;
    border-radius: 50px / 100px;
    bottom: 60px;
}



/*portaal left*/
.portaal_links {
    background: radial-gradient(ellipse at center, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
    transition: box-shadow ease-in-out;
    transition-delay: 1s;
    transition-duration: 1s;
    box-shadow: 0 0 55px #57B6FF;
    opacity: 0.75;
    left: 50px;
    animation:mvv 2s infinite;
}
@keyframes mvv{
   0%{
         box-shadow: 0 0 55px #57B6FF;
   }
   50%{
         box-shadow: 0 0 0px #57B6FF;
   }
}

.portaal_rechts {
    background: radial-gradient(ellipse at center, rgba(243,197,189,1) 0%,rgba(232,108,87,1) 50%,rgba(234,40,3,1) 51%,rgba(255,102,0,1) 75%,rgba(199,34,0,1) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
    box-shadow: 0 0 55px #FF6600;
    opacity: 0.55;
    left: 750px;
    animation:mv 2s infinite;
}
@keyframes mv{
   0%{
         box-shadow: 0 0 55px #FF6600;
   }
   50%{
         box-shadow: 0 0 0px #FF6600;
   }
}