亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

包含文本的圖像的包裝 div 無法同時更改圖像上的亮度濾鏡和更改文本上的不透明度濾鏡

包含文本的圖像的包裝 div 無法同時更改圖像上的亮度濾鏡和更改文本上的不透明度濾鏡

小怪獸愛吃肉 2023-09-11 15:36:57
這是我的代碼:超文本標記語言<div id="featuredWrapper">    <div id="featuredContentWrapper">        <div class="ContentThumbnail">            <a>                <div class="ContentThumbnailCaption">                    <h3>Lorem</h3>                    <p>Ipsum</p>                </div>                <img src="https://i.picsum.photos/id/1/200/300.jpg" class="ContentThumbnailImage" />            </a>        </div>    </div></div>CSS #featuredWrapper    {        /*SETUP*/        display:inline-block;        margin-left:13.85%;        margin-right:13.85%;        width:72.3%;        /*BORDER*/        border-bottom: solid 1px gray;        /*ANIMATION*/        transition: 0.3s;    }    #featuredContentWrapper    {        /*SETUP*/        text-align:center;    }    .ContentThumbnail    {        /*SETUP*/        display:inline-block;        height: 30%;        width: 22.5%;        margin: 2% 4% 2% 4%;        /*VISUAL*/        background-color:aqua;        /*ANIMATION*/        transition: 0.3s;    }     .ContentThumbnail:hover .ContentThumbnailCaption    {        /*VISUAL*/       filter:opacity(100%);    }    .ContentThumbnail:hover .ContentThumbnailImage    {       /*VISUAL*/       filter:brightness(50%);    }          .ContentThumbnail a    {        /*SETUP*/        display:inline-block;        position:relative;    }    .ContentThumbnailImage    {        /*SETUP*/        display:inline-block;        height: 100%;        width: 100%;    }    .ContentThumbnailCaption    {        /*SETUP*/        position:absolute;        top: 50%;        left: 50%;        transform: translate(-50%, -50%);        /*VISUAL*/        color:white;        filter:opacity(0);        /*ANIMATION*/        transition:0.3s;             }我希望亮度和不透明度變化同時發生,以便文本顯示在變暗的圖像上。就目前情況而言,我認為要么亮度濾鏡以某種方式隱藏了文本,要么效果相繼發生,因為當您停止懸停時,文本將出現并播放淡出動畫。我嘗試過更改用于實現這兩種效果的機制,例如使用可見性 CSS 而不是過濾器。我還沒有嘗試過 JavaScript,但我想在 CSS 中保留這種效果。
查看完整描述

1 回答

?
波斯汪

TA貢獻1811條經驗 獲得超4個贊

更改為下面提到的 css


 .ContentThumbnail:hover .ContentThumbnailCaption

   /*VISUAL*/

   filter:opacity(100%);z-index:1;

}

#featuredWrapper {

  /*SETUP*/

  display: inline-block;

  margin-left: 13.85%;

  margin-right: 13.85%;

  width: 72.3%;

  /*BORDER*/

  border-bottom: solid 1px gray;

  /*ANIMATION*/

  transition: 0.3s;

}


#featuredContentWrapper {

  /*SETUP*/

  text-align: center;

}


.ContentThumbnail {

  /*SETUP*/

  display: inline-block;

  height: 30%;

  width: 22.5%;

  margin: 2% 4% 2% 4%;

  /*VISUAL*/

  background-color: aqua;

  /*ANIMATION*/

  transition: 0.3s;

}


.ContentThumbnail:hover .ContentThumbnailCaption {

  /*VISUAL*/

  filter: opacity(100%);

  z-index: 1;

}


.ContentThumbnail:hover .ContentThumbnailImage {

  /*VISUAL*/

  filter: brightness(50%);

}


.ContentThumbnail a {

  /*SETUP*/

  display: inline-block;

  position: relative;

}


.ContentThumbnailImage {

  /*SETUP*/

  display: inline-block;

  height: 100%;

  width: 100%;

}


.ContentThumbnailCaption {

  /*SETUP*/

  position: absolute;

  top: 50%;

  left: 50%;

  transform: translate(-50%, -50%);

  /*VISUAL*/

  color: white;

  filter: opacity(0);

  /*ANIMATION*/

  transition: 0.3s;

}

<div id="featuredWrapper">

  <div id="featuredContentWrapper">

    <div class="ContentThumbnail">

      <a>

        <div class="ContentThumbnailCaption">

          <h3>Lorem</h3>

          <p>Ipsum</p>

        </div>

        <img src="https://i.picsum.photos/id/1/200/300.jpg" class="ContentThumbnailImage" />


      </a>

    </div>

  </div>

</div>


查看完整回答
反對 回復 2023-09-11
  • 1 回答
  • 0 關注
  • 107 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號