zoukankan      html  css  js  c++  java
  • 【css】用纯 CSS 判断鼠标进入的方向

    代码

    <style>
        body {
            padding: 2em;
            text-align: center;
        }
        .block {
            position: relative;
            display: inline-block;
            overflow:hidden;
             10em;
            height: 10em;
            vertical-align: middle;
            transform: translateZ(0);
        }
        .block_hoverer {
            position: absolute;
            z-index: 1;
             100%;
            height: 100%;
            opacity: 0;
            transition: all .3s ease;
        }
    
        .block_hoverer:nth-child(1) {
            background: red;
            top: -90%;
        }
    
        .block_hoverer:nth-child(2) {
            background: lime;
            top: 90%;
        }
    
        .block_hoverer:nth-child(3) {
            background: orange;
            left: -90%;
        }
    
        .block_hoverer:nth-child(4) {
            background: blue;
            left: 90%;
        }
        .block_hoverer:hover {
            opacity: 1;
            top: 0;
            left: 0;
        }
    
        .block_content {
            position: absolute;
            top: 0;
            left: 0;
             100%;
            height: 100%;
            text-align: center;
            line-height: 10em;
            background: #333;
            color: #FFF;
        }
    </style>
    <body>
        <p class="text">从不同方向使鼠标指针移过下面的内容</p>
        <p>↓</p>
        <span>→ </span>
        <div class="block">
            <div class="block_hoverer">1</div>
            <div class="block_hoverer">2</div>
            <div class="block_hoverer">3</div>
            <div class="block_hoverer">4</div>
            <div class="block_content">
                Hover me!
            </div>
        </div>
        <span> ←</span>
        <p>↑</p>
    </body>
    
    

    效果:

  • 相关阅读:
    针对web高并发量的处理
    外边距合并,外边距折叠
    cookie 和session 的区别:
    ng-if ng-show ng-hide 的区别
    JavaScript中的arguments,callee,caller
    git常见命令
    jQuery中.bind() .live() .delegate() .on()的区别
    为什么要使用sass
    js兼容性记录
    poj1004
  • 原文地址:https://www.cnblogs.com/richerdyoung/p/12911738.html
Copyright © 2011-2022 走看看