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