How to use CSS to make a mask layer appear when the mouse is hovering

不言
Release: 2018-06-20 17:52:03
Original
3310 people have browsed it

This article shares with you the effect of two mouse hovers showing the mask layer. You can choose a certain effect according to your own needs. Example codes for both effects are given in the article. Let’s take a look. Bar.

Let’s start with a simple implementation method:

<!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>
 <p id="my-mask" class="mask-wrapper">
    <p>Lorem ipsum</p>
    <p class="mask-inner">
        <p>foo bar</p>
    </p>
</p>
</body>
</html>
Copy after login

Let’s do a more advanced one:

<!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>
            <p class="info">服装</p>
        </li>
        <li class="box">
            <i class="shadow"></i>
            <i class="icon">B</i>
            <p class="info">鞋包</p>
        </li>
        <li class="box">
            <i class="shadow"></i>
            <i class="icon">C</i>
            <p class="info">配饰</p>
        </li>
        <li class="box">
            <i class="shadow"></i>
            <i class="icon">D</i>
            <p class="info">运动</p>
        </li>
    </ul>
</p>
</body>
</html>
Copy after login

The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

How to use CSS to achieve the effect of mouse-up icon rotation

How to use CSS pointer- The events attribute implements the mouse penetration effect

#

The above is the detailed content of How to use CSS to make a mask layer appear when the mouse is hovering. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template