Another small application of CSS pseudo-classes, implementing the drop-down menu

Source: Internet
Author: User

Implementation ideas:

The menu is contained in a div. The height of the div is 30px, And the menu length is 120px. Set the overflow of the div to hidden.

In this way, the remaining 90px contents of the menu are hidden.

When hover is used, set the div overflow value to visible. In this way, the remaining 90px content is visible.

The Demo code is as follows:

 
 
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  2.     <style type="text/css"> 
  3.         .tdiv  
  4.         {  
  5.             width: 100px;  
  6.             height: 30px;  
  7.             overflow: hidden;  
  8.             text-align: center;  
  9.             background: red;  
  10.         }  
  11.         .tdiv:hover  
  12.         {  
  13.             overflow: visible;  
  14.               
  15.         }  
  16.     </style> 
  17. <body> 
  18.     <div class="tdiv"> 
  19.         <div style="width: 100px; height: 30px; background: green; text-align: center;"> 
  20.             Menu1</div> 
  21.         <div style="width: 100px; height: 30px; background: green; text-align: center;"> 
  22.             Menu2</div> 
  23.         <div style="width: 100px; height: 30px; background: green; text-align: center;"> 
  24.             Menu3</div> 
  25.         <div style="width: 100px; height: 30px; background: green; text-align: center;"> 
  26.             Menu4</div> 
  27.     </div> 
  28. </body> 

 

This article is from the "one blog" blog, please be sure to keep this source http://cnn237111.blog.51cto.com/2359144/959338

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.