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

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

合并兩個類 div

合并兩個類 div

holdtom 2023-06-15 17:08:49
我正在嘗試將兩個 div 類組合在一起,這樣它就可以工作了。我正在嘗試將這些東西組合在一起,但我不能。我該怎么做?唯一有效的是搖動圖像,我希望兩者一起工作。我現在將鏈接一的 .overlay 放入自動風格3。CSS代碼是img:hover {? animation: shake 0.2s;? animation-iteration-count: infinite;}@keyframes shake {? 0% { transform: translate(1px, 1px) rotate(0deg); }? 10% { transform: translate(-1px, -2px) rotate(-1deg); }? 20% { transform: translate(-3px, 0px) rotate(1deg); }? 30% { transform: translate(3px, 2px) rotate(0deg); }? 40% { transform: translate(1px, -1px) rotate(1deg); }? 50% { transform: translate(-1px, 2px) rotate(-1deg); }? 60% { transform: translate(-3px, 1px) rotate(0deg); }? 70% { transform: translate(3px, 1px) rotate(-1deg); }? 80% { transform: translate(-1px, -1px) rotate(1deg); }? 90% { transform: translate(1px, 2px) rotate(0deg); }? 100% { transform: translate(1px, -2px) rotate(-1deg); }}.auto-style3 {? ? margin-top: 0px;? ? ?position: absolute;?? bottom: 0;?? background: rgb(0, 0, 0);? background: rgba(0, 0, 0, 0.5); /* Black see-through */? color: #f1f1f1;?? width: 100%;? transition: .5s ease;? opacity:0;? color: white;? font-size: 20px;? padding: 20px;? text-align: center;}.auto-style4 {? ? background-color: #FF0000;}* {box-sizing: border-box;}.container {? position: relative;? width: 50%;? max-width: 300px;}.image {? display: block;? width: 100%;? height: auto;}.container:hover .overlay {? opacity: 1;}我的代碼是?<div class="container"? >? ??? <img src="avatar.jpg" alt="Avatar" width="278" height="262" class="style3" >? <div class="auto-style3">? Avatar is ON? </div>? </div>
查看完整描述

1 回答

?
素胚勾勒不出你

TA貢獻1827條經驗 獲得超9個贊

我從兩個來源直接復制/粘貼,然后更改了下面代碼片段中的第一行 CSS ( img:hover-> .container:hover)


.container:hover {

  /* Start the shake animation and make the animation last for 0.5 seconds */

  animation: shake 0.5s;


  /* When the animation is finished, start again */

  animation-iteration-count: infinite;

}


@keyframes shake {

  0% { transform: translate(1px, 1px) rotate(0deg); }

  10% { transform: translate(-1px, -2px) rotate(-1deg); }

  20% { transform: translate(-3px, 0px) rotate(1deg); }

  30% { transform: translate(3px, 2px) rotate(0deg); }

  40% { transform: translate(1px, -1px) rotate(1deg); }

  50% { transform: translate(-1px, 2px) rotate(-1deg); }

  60% { transform: translate(-3px, 1px) rotate(0deg); }

  70% { transform: translate(3px, 1px) rotate(-1deg); }

  80% { transform: translate(-1px, -1px) rotate(1deg); }

  90% { transform: translate(1px, 2px) rotate(0deg); }

  100% { transform: translate(1px, -2px) rotate(-1deg); }

}


.container {

  position: relative;

  width: 100%;

  max-width: 400px;

}


.image {

  display: block;

  width: 100%;

  height: auto;

}


.overlay {

  position: absolute;

  top: 0;

  bottom: 0;

  left: 0;

  right: 0;

  height: 100%;

  width: 100%;

  opacity: 0;

  transition: .3s ease;

  background-color: red;

}


.container:hover .overlay {

  opacity: 1;

}


.icon {

  color: white;

  font-size: 100px;

  position: absolute;

  top: 50%;

  left: 50%;

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

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

  text-align: center;

}


.fa-user:hover {

  color: #eee;

}

<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>


<div class="container">

  <img src="https://www.w3schools.com/howto/img_avatar.png" alt="Avatar" class="image">

  <div class="overlay">

    <a href="#" class="icon" title="User Profile">

      <i class="fa fa-user"></i>

    </a>

  </div>

</div>


查看完整回答
反對 回復 2023-06-15
  • 1 回答
  • 0 關注
  • 150 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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