【问题标题】:background image and color together [duplicate]背景图像和颜色一起[重复]
【发布时间】:2016-04-06 16:25:43
【问题描述】:

如何给一个 div 一个背景图像,然后让它变暗一点,当我将鼠标悬停在 div 上时,我希望删除更暗

<div id="bg">
   <h1>Cat</h1>
</div>

css:

    #bg{
      height: 200px;
      width: 200px;
      background: rgba(0,0,0,0.7) url(http://i.imgur.com/IMiabf0.jpg) ;
      background-size: cover;
      color: red
    }
    #bg:hover{
     background:url(http://i.imgur.com/IMiabf0.jpg) ;
    }

【问题讨论】:

    标签: css


    【解决方案1】:

    试试这个:

    #bg{
      height: 200px;
      width: 200px;
      background:linear-gradient(rgba(0,0,0, 0.7), rgba(0,0,0, 0.7)), url(http://i.imgur.com/IMiabf0.jpg) ;
      background-size: cover;
      color: red
    }
    #bg:hover{
      background:url(http://i.imgur.com/IMiabf0.jpg) ;
      background-size: cover;
    }
    

    【讨论】:

    • 一个小小的解释会是一个很好的答案
    猜你喜欢
    • 2021-05-13
    • 2011-07-22
    • 1970-01-01
    • 1970-01-01
    • 2011-01-09
    • 2019-03-31
    • 2012-03-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多