Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将CSS3变换与渐变背景一起使用_Css_Gradient_Css Transitions - Fatal编程技术网

将CSS3变换与渐变背景一起使用

将CSS3变换与渐变背景一起使用,css,gradient,css-transitions,Css,Gradient,Css Transitions,我尝试在悬停时在缩略图上使用css进行过渡,以便在悬停时背景渐变淡入。转换不起作用,但如果我简单地将其更改为rgba()值,它就可以正常工作。是否不支持渐变?我也尝试过使用图像,它也不会转换图像 我知道这是可能的,就像在另一篇文章中有人做的那样,但我不知道到底是怎么做的。任何帮助>这里有一些CSS可以使用: #集装箱部门a{ -webkit过渡:背景0.2s线性; -moz过渡:背景0.2s线性; -o-过渡:背景0.2s线性; 过渡:背景0.2s线性; 位置:绝对位置; 宽度:200px; 高

我尝试在悬停时在缩略图上使用css进行过渡,以便在悬停时背景渐变淡入。转换不起作用,但如果我简单地将其更改为
rgba()
值,它就可以正常工作。是否不支持渐变?我也尝试过使用图像,它也不会转换图像

我知道这是可能的,就像在另一篇文章中有人做的那样,但我不知道到底是怎么做的。任何帮助>这里有一些CSS可以使用:

#集装箱部门a{
-webkit过渡:背景0.2s线性;
-moz过渡:背景0.2s线性;
-o-过渡:背景0.2s线性;
过渡:背景0.2s线性;
位置:绝对位置;
宽度:200px;
高度:150像素;
边框:1px#000实心;
利润率:30像素;
z指数:2
}
#货柜舱a组:悬停{
背景:-webkit梯度(径向,1007510010075,0,从(rgba(0,0,0,7))到(rgba(0,0,0,4)))
}

渐变还不支持过渡(尽管当前规范说它们应该支持通过插值进行的类似渐变到类似渐变的过渡)

如果想要背景渐变的淡入效果,则必须在容器元素上设置不透明度,并对不透明度进行“过渡”

(有一些浏览器版本支持渐变过渡(例如IE10。我在2016年在IE中测试了渐变过渡,当时它们似乎可以工作,但我的测试代码不再工作。)

更新日期:2018年10月
带有未加前缀的新语法的渐变过渡[例如,径向渐变(…)]现在已确认(再次?)在Microsoft Edge 17.17134上有效。我不知道这是何时添加的。在最新的Firefox和Chrome/Windows 10上仍然不起作用。

渐变还不支持过渡(尽管当前规范说它们应该支持通过插值进行的类似渐变到类似渐变的过渡。)

如果想要背景渐变的淡入效果,则必须在容器元素上设置不透明度,并对不透明度进行“过渡”

(有一些浏览器版本支持渐变过渡(例如IE10。我在2016年在IE中测试了渐变过渡,当时它们似乎可以工作,但我的测试代码不再工作。)

更新日期:2018年10月
带有未加前缀的新语法的渐变过渡[例如,径向渐变(…)]现在已确认(再次?)在Microsoft Edge 17.17134上有效。我不知道这是何时添加的。在最新的Firefox和Chrome/Windows 10上仍然不起作用。

一种解决方法是变换背景位置,以产生渐变正在改变的效果:

带背景位置的CSS3梯度变换 虽然不能使用CSS transition属性直接设置渐变动画,但可以设置background position属性的动画以实现简单的渐变动画:

这方面的代码非常简单:

#DemoGradient{
背景:-webkit线性梯度(#C7D3DC,#5B798E);
背景:-莫兹线性梯度(#C7D3DC,#5B798E);
背景:-o-线性梯度(#C7D3DC,#5B798E);
背景:线性梯度(#C7D3DC,#5B798E);
-webkit过渡:背景1s缓解;
-moz转换:背景1s放松;
-o型过渡:背景1s缓解;
过渡:背景1s放松;
背景尺寸:1px200px;
边界半径:10px;
边框:1px实心#839DB0;
光标:指针;
宽度:150px;
高度:100px;
}  
#人口梯度:悬停{
背景位置:100px;
}

一个解决方法是转换背景位置,以产生渐变正在改变的效果:

带背景位置的CSS3梯度变换 虽然不能使用CSS transition属性直接设置渐变动画,但可以设置background position属性的动画以实现简单的渐变动画:

这方面的代码非常简单:

#DemoGradient{
背景:-webkit线性梯度(#C7D3DC,#5B798E);
背景:-莫兹线性梯度(#C7D3DC,#5B798E);
背景:-o-线性梯度(#C7D3DC,#5B798E);
背景:线性梯度(#C7D3DC,#5B798E);
-webkit过渡:背景1s缓解;
-moz转换:背景1s放松;
-o型过渡:背景1s缓解;
过渡:背景1s放松;
背景尺寸:1px200px;
边界半径:10px;
边框:1px实心#839DB0;
光标:指针;
宽度:150px;
高度:100px;
}  
#人口梯度:悬停{
背景位置:100px;
}

如上所述。CSS转换当前不支持渐变。但在某些情况下,您可以通过将其中一种颜色设置为透明,使其他包装元素的背景色发光,然后进行转换来解决此问题。

如上所述。CSS转换当前不支持渐变但是,在某些情况下,您可以通过将其中一种颜色设置为透明,使其他包装元素的背景色发光,然后进行过渡来解决此问题。

您可以使用一些堆叠渐变的不透明度中的过渡来模拟渐变之间的过渡,如一些答案中所述在这里:

您也可以转换位置,如下所述:

这里还有一些技巧:


.

您可以使用一些堆叠渐变的不透明度中的过渡来模拟渐变之间的过渡,如以下几个答案所述:

您也可以转换位置,如下所述:

这里还有一些技巧:


.

解决方案是使用背景位置来模拟渐变过渡。 这个解决方案在Twitter上使用过
 .btn {
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 12px;
  font-weight: 300;
  position: relative;
  display: inline-block;
  text-decoration: none;
  color: #fff;
  padding: 20px 40px;
  background-image: -moz-linear-gradient(top, #50abdf, #1f78aa);
  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#50abdf), to(#1f78aa));
  background-image: -webkit-linear-gradient(top, #50abdf, #1f78aa);
  background-image: -o-linear-gradient(top, #50abdf, #1f78aa);
  background-image: linear-gradient(to bottom, #50abdf, #1f78aa);
  background-repeat: repeat-x;
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff50abdf', endColorstr='#ff1f78aa', GradientType=0);
  background-repeat: repeat-y;
  background-size: 100% 90px;
  background-position: 0 -30px;
  -webkit-transition: all 0.2s linear;
     -moz-transition: all 0.2s linear;
       -o-transition: all 0.2s linear;
          transition: all 0.2s linear;
}
.btn:hover {
   background-position: 0 0;
}
.bkgrndfar {
  position:absolute;
  top:0;
  left:0;
  z-index:-2;
  height:100%;
  width:100%;
  background:linear-gradient(#eee, #aaa);
}

.bkgrndnear {
  position:absolute;
  top:0;
  left:0;
  height:100%;
  width:100%;
  background:radial-gradient(at 50% 50%, blue 1%, aqua 100%);
  opacity:0;
  transition: opacity 1s;
}

a.menulnk {
  position:relative;
  text-decoration:none;
  color:#333;
  padding: 0 20px;
  text-align:center;
  line-height:27px;
  float:left;
}

a.menulnk:hover {
  color:#eee;
  text-decoration:underline;
}

/* This transitions child opacity on parent hover */
a.menulnk:hover .bkgrndnear {
  opacity:1;
}
<a href="#" class="menulnk">Transgradient
<div class="bkgrndfar">
  <div class="bkgrndnear">
  </div>
</div>
</a>
#wrapper{
    width:400px;
    height:400px;
    margin:0 auto;
    border: 1px #000 solid;
    position:relative;}
#wrapper:after,
#wrapper:before{
    position:absolute;
    top:0;
    left:0;
    width:100%;
    height:100%;
    content:'';
    background: #1e5799;
    background: -moz-linear-gradient(top, #1e5799 0%, #2989d8 50%, #207cca 51%, #7db9e8 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#1e5799), color-stop(50%,#2989d8), color-stop(51%,#207cca), color-stop(100%,#7db9e8));
    background: -webkit-linear-gradient(top, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%);
    background: -o-linear-gradient(top, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%);
    background: -ms-linear-gradient(top, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%);
    background: linear-gradient(to bottom, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%);
    opacity:1;
    z-index:-1;
    -webkit-transition: all 2s ease-out;
    -moz-transition: all 2s ease-out;
    -ms-transition: all 2s ease-out;
    -o-transition: all 2s ease-out;
    transition: all 2s ease-out;
}
#wrapper:after{
    opacity:0;
    background: #87e0fd;
    background: -moz-linear-gradient(top, #87e0fd 0%, #53cbf1 40%, #05abe0 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#87e0fd), color-stop(40%,#53cbf1), color-stop(100%,#05abe0));
    background: -webkit-linear-gradient(top, #87e0fd 0%,#53cbf1 40%,#05abe0 100%);
    background: -o-linear-gradient(top, #87e0fd 0%,#53cbf1 40%,#05abe0 100%);
    background: -ms-linear-gradient(top, #87e0fd 0%,#53cbf1 40%,#05abe0 100%);
    background: linear-gradient(to bottom, #87e0fd 0%,#53cbf1 40%,#05abe0 100%);
}
#wrapper:hover:before{opacity:0;}
#wrapper:hover:after{opacity:1;}
.button SPAN {
    padding: 10px 30px; 
    border: 1px solid ##009CC5;

    -moz-box-shadow: inset 0 0 20px 1px #00a7d1;
    -webkit-box-shadow: inset 0 0 20px 1px#00a7d1;
    box-shadow: inset 0 0 20px 1px #00a7d1; 

    background-color: #00a7d1;
    -webkit-transition: background-color 0.5s linear;
    -moz-transition: background-color 0.5s linear;
    -o-transition: background-color 0.5s linear;
    transition: background-color 0.5s linear;
}

.button SPAN:hover {
    background-color: #00c5f7; 
}
.ahover {
    display: block;
    /** text-indent: -999em; ** if u use only only img **/
    position: relative;
}
.ahover:after {
    content: "";
    height: 100%;
    left: 0;
    opacity: 0;
    position: absolute;
    top: 0;
    transition: all 0.5s ease 0s;
    width: 100%;
    z-index: 1;
}
.ahover:hover:after {
    opacity: 1;
}
.ahover span {
    display: block;
    position: relative;
    z-index: 2;
}
$('#element').gradientFade({

    duration: 2000,
    from: '(20,20,20,1)',
    to: '(120,120,120,0)'
});
/* overlay */
z-index : 1;
background : radial-gradient( ellipse at 25% 25%, rgba( 255, 255, 255, 0 ) 0%, rgba( 0, 0, 0, 1 ) 100% );
transition : all 1s cubic-bezier(0.25, 0.46, 0.45, 0.94);

.element {
  position: relative;
  width: 500px;
  height: 400px;
  background-image: linear-gradient(45deg, blue, aqua);
  z-index: 2;
}

.element::before {
  position: absolute;
  content: "";
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background-image: linear-gradient(to bottom, red, orange);
  z-index: 1;
  opacity: 0;
  transition: opacity 0.4s linear;
}

.element:hover::before {
  opacity: 1;
}