The DIV CSS mouse hovers over the picture when the text appears above the picture

Source: Internet
Author: User

div CSS Mouse hover over the picture when there is no text content above the picture display text, is completely pure CSS div implementation. CSS implementation of the mouse hover over the picture above the display of beautification content.

The original picture shows no text above, the text is displayed when the mouse hovers over, and the text background is translucent. You can use pure div+css to realize the display of text content on a mouse hover picture.

Pure DIV+CSS Implementation of the first picture without text content, mouse hover when the second picture appears as the effect

Using div CSS to display the text content above the mouse hover picture principle: First we set up a box object, and the picture is set as a CSS background image using the style tag, and set the object HTML a hyperlink Display:none hidden, The hyperlink anchor text is placed inside the text content, and finally set the mouse hover over the entire object when the hyperlink content is displayed.

It is important to note that we used the CSS position absolute positioning hyperlink a tag underneath the box object, and to beautify the effect to the HTML a tag width is the same as the object width, set a certain height, set the CSS background is a translucent background color.

In order to be compatible with IE6 we use the IE6 support hover plugin. Control reading understand IE6 hover support. This effect is compatible with all major browsers including IE6.

The full HTML source code is as follows:

  1. <! DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <Meta charset="utf-8" />
  5. <title> Mouse hover picture on display text online demo www.divcss5.com</title>
  6. <style>
  7. img{border:0}/* CSS Comment Description: Set picture border is 0 */
  8. Body{behavior:url ("CSSHOVER.HTC"); text-align:center;} /* CSS Comment Description: Compatible with IE6 support tag using hover */
  9. . divcss5{position:relative;width:554px; height:346px;margin:0 Auto}
  10. . divcss5 a,.divcss5 span{display:none; Text-decoration:none}
  11. . Divcss5:hover{cursor:pointer}
  12. Divcss5:hover a.now{cursor:pointer; position:absolute; top:0; width:100%; height:100%; z-index:100; left:0; display: Block;}
  13. . divcss5:hover span{Display:block;position:absolute; bottom:0; Left:0;color: #FFF; width:554px; z-index:10;height : 36px; line-height:36px; Background: #000; Filter:alpha (opacity=60);-moz-opacity:0.5;opacity:0.5;}
  14. /* Set display text positioning position, background translucent */
  15. </style>
  16. </head>
  17. <body>
  18. <div class="divcss5" style="Background:url (imgexp.png)">
  19. <span> Text content </span>
  20. <a href="#" class="Now">&nbsp; </a>
  21. </div>
  22. <div class="divcss5" style="Background:url (imgexp.png)">
  23. <span> Welcome visit DIVCSS5 website </span >
  24. <a href= "http://www.divcss5.com/"  class= "Now" >&nbsp; </a> 
  25. </div>
  26. </body>
  27. </html>

This picture shows and hides the text content to be simple and practical, the program uses conveniently. In particular, we use the style property in the diameter of the label and background the background image to make the program good to use.

Pure Css+div realization of the mouse on the picture above the text content effect

http://www.divcss5.com/yanshi/2014/2014061902/

Http://www.divcss5.com/css-texiao/texiao714.shtml

DIV css mouse hover over picture to display text above the picture (go)

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.