CSS Hover masking layer

Source: Internet
Author: User

Immediately at the end of the month, busy with work and life, not a good blog, a little sad. To make up, just write something simple.

A recent project has a need to show a layer when the mouse is moved in and the layer disappears when it is removed. Of course the layer can be clicked for extra action.

The project is react, the first use of the Mounseenter and Mounseleave events, the results of the click into another route, click Back again, the mouse on the element, there is no more floating layer. It's embarrassing.

At that time also want to use the event, but think now CSS3 mouse event, animation, Pseudo-class selector so mature. Extra to search for a little bit, you seem to have seen the relevant articles before.

Later found that hover this pseudo-class can indeed be relatively handsome. Of course we can only control the sub-elements (so to speak, I have time to think and ponder).

The basic implementation of the mask layer, that is, the mask is set to absolute positioning, the default is hidden, hover, the time, show, basically this is. Mounseenter and Mounseleave of the guard, you quickly move, always will be a little inexplicable problem come out. This is a lifesaver.

This is the basic structure of the Code.

 <style type="text/css">    .container{        width:400px;height:200px;        background-color: blueviolet    }    .layer{        background-color:#8bb907;        display:none;        height: 100%;        width: 100%;        text-align: center;    }    .container:hover .layer{display:block;}</style><body>    <div class="container">        <div class="layer">                   <a href="http://www.baidu.com">百度</a>           </div>    </div>   </body>

Another is the IMG default image load Failure problem, I began to confidently write down

As a result you will find that the SRC address is incorrect or the load fails when the Leng awkward, how to do,

The following is a better scenario, if the load fails, the default is displayed.

ev.target.src= "htpp://xxxxx.png"} />

Some people say, oh, so ah, actually not finished. If your default picture fails, is it always loading repeatedly? Haha, get it.

CSS Hover masking layer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.