如何应用背景渐变样式css

时间:2018-03-01 05:11:11

标签: css background styles gradient opacity

我想像这样应用nackground渐变样式 - > http://nimb.ws/Xq79Uw

以下是HTML代码:

<div class="featured-title zl-artful-featured-title">
   <aside class="post-meta cf">
      <a aria-label="Artful Interiors" class="cat-artful-interiors" href="http://localhost/magnifissance/?cat=86">Artful Interiors</a>                                          
   </aside>
   <div class="row">
      <div class="columns medium-10">
         <div class="post-title zl-artful-interi-title">
            <a href="http://localhost/magnifissance/?p=12466">Enrico Fratesi Shares His Vision of Form, Tradition and Renewal</a>
         </div>
      </div>
      <div class="columns medium-2">
         <figure class="post-gallery "></figure>
      </div>
   </div>
</div>

任何人都有这种风格的想法,请更新我。

感谢。

2 个答案:

答案 0 :(得分:1)

看起来渐变位于示例中的图像顶部。使用伪元素的代码将为您做到这一点,而不是将梯度代码放在div本身上。

#artful_interiors .post > a {
    position: relative;
}

#artful_interiors .post > a:before {
    content: " ";
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient( to bottom, rgba(0,0,0,0) 50%, #000 95% );
}

答案 1 :(得分:0)

&#13;
&#13;
#zl-artful-featured-title{
   background: linear-gradient(
    to top,
    #63B4C9  35%,
    #FFFFFF 70%
  );
  background-repeat: no-repeat;
  height:260px;
  width:100%;
}
&#13;
<div id="zl-artful-featured-title">
    <p>Content</p>
    <img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTvbOaFeLuR9IUkcut98bJs4r7-Qm8AGcEEYiiKxiAZEiljvUS_"/>
</div>
&#13;
&#13;
&#13;

试试这个

#zl-artful-featured-title{
  background-image: -webkit-linear-gradient(90deg, #63B4C9 35%, #FFFFFF 40%);

}

如果不能正常运行,请尝试

 #zl-artful-featured-title{
  background: linear-gradient(
    to bottom,
    #63B4C9  35%,
    #FFFFFF 70%
  );
}

确保您已将#更改为。如果你的使用课。 我希望它有所帮助