溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

CSS如何實現鼠標懸浮出現遮罩層

發布時間:2021-03-20 09:42:34 來源:億速云 閱讀:572 作者:小新 欄目:web開發

這篇文章給大家分享的是有關CSS如何實現鼠標懸浮出現遮罩層的內容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。

先來一個簡單的實現方法:

代碼如下:

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <title>Document</title>
 <style type="text/css">
  .mask-wrapper {
      position: relative;
      overflow: hidden;
  }
  .mask-inner {
      position: absolute;
      left: 0;
      top: 100%;
      width: 100%;
      height: 100%;
      -moz-transition: top ease 200ms;
      -o-transition: top ease 200ms;
      -webkit-transition: top ease 200ms;
      transition: top ease 200ms;
  }
  .mask-wrapper:hover .mask-inner {
      top: 0;
  }
  #my-mask {
      width: 300px;
      height: 200px;
      background: red;
  }
  #my-mask .mask-inner {
      background: rgba(0,0,0,.5);
  }
 </style>
</head>
<body>
 <div id="my-mask" class="mask-wrapper">
    <p>Lorem ipsum</p>
    <div class="mask-inner">
        <p>foo bar</p>
    </div>
</div>
</body>
</html>

來個更高級點的:

代碼如下:

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <title>Document</title>
 <style type="text/css">
  * {
      margin: 0;
      padding: 0;
  }
  body {
      font: 12px/1.5 arail;
  }
  ul {
      list-style: none;
  }
  .icon-lists {
      overflow: hidden;
      background: #f7f7f7;
      padding: 40px;
  }
  .icon-lists .box {
      float: left;
      margin-right: 10px;
  }
  .box {
      position: relative;
      width: 46px;
      height: 46px;
      overflow: hidden;
      z-index: 1;
  }
  .box i, .box .info {
      display: block;
      width: 46px;
      height: 46px;
      border-radius: 46px;
  }
  .box .shadow {
      position: absolute;
      top: 0;
      z-index: 10;
      border-radius: 0;
      background: url(<a href="http://xiaomingming.qiniudn.com/shadow.png">http://xiaomingming.qiniudn.com/shadow.png</a>) no-repeat;
  }
  .box .icon {
      position: absolute;
      top: 0;
      line-height: 46px;
      text-align: center;
      background: #eee;
      color: #333;
      font-size: 14px;
  }
  .box .info {
      position: absolute;
      top: 46px;
      z-index: 2;
      background: orange;
      color: #fff;
      text-align: center;
      line-height: 46px;
      -webkit-transition:top .2s ease-in;
      -moz-transition:top .2s ease-in;
      transition:top .2s ease-in;
  }
  .box:hover>.info {
      top:0;
  }</p>
<p> </style>
</head>
<body>
     <ul class="icon-lists">
        <li class="box">
            <i class="shadow"></i>
            <i class="icon">A</i>
            <div class="info">服裝</div>
        </li>
        <li class="box">
            <i class="shadow"></i>
            <i class="icon">B</i>
            <div class="info">鞋包</div>
        </li>
        <li class="box">
            <i class="shadow"></i>
            <i class="icon">C</i>
            <div class="info">配飾</div>
        </li>
        <li class="box">
            <i class="shadow"></i>
            <i class="icon">D</i>
            <div class="info">運動</div>
        </li>
    </ul>
</div>
</body>
</html>

感謝各位的閱讀!關于“CSS如何實現鼠標懸浮出現遮罩層”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

css
AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女