In fact, the concept of CSS sliding doors has appeared a few years ago, but it has been mentioned more often in recent years. But people often confuse it with the tab effect, especially some novice friends, so I will write a detailed explanation here, hoping it will be helpful.
Speaking of which, sliding doors are not a sophisticated technology, they are just a CSS technique. It uses the overlap and sliding of background images to achieve some effects. The most common one is rounded corner navigation. We can imagine the two rounded corner backgrounds, one on the left and one on the right, as two sliding doors. They can slide together and overlap to display less content, or they can slide against each other. Open to display more content, as shown below:
In some previous tutorials, I liked to cut the background image into two parts, one wide and one narrow, for splicing. In fact, one image is enough.
Here, we only use the two tags "a" and "span". The style can define three states, which can be said to be the simplest way.
The following is the quoted content: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <html xmlns=" http://www.w3.org/1999/xhtml "> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style> body {font-size:12px;} .nav {margin:0 auto; text-align:center; font-weight:bold; border-bottom:3px solid #579cc6;} .nav a {display:inline-block; margin:0 3px; height:25px; background:url( https://images.downcodes.com/u/info_img/2009-05/30/0158361.jpg ) left bottom no-repeat; padding-left:15px; color:#666; text-decoration:none; cursor:pointer;} .nav a span {display:inline-block; height:25px; line-height:25px; background:url( https://images.downcodes.com/u/info_img/2009-05/30/0158361.jpg ) right bottom no-repeat; padding-right: 15px;} .nav a:hover {background:url( https://images.downcodes.com/u/info_img/2009-05/30/0158361.jpg ) left top no-repeat; color:#FFF;} .nav a:hover span {background:url( https://images.downcodes.com/u/info_img/2009-05/30/0158361.jpg ) right top no-repeat;} .nav a.set {background:url( https://images.downcodes.com/u/info_img/2009-05/30/0158361.jpg ) left top no-repeat; color:#FFF; } .nav a.set span {background:url( https://images.downcodes.com/u/info_img/2009-05/30/0158361.jpg ) right top no-repeat;} </style> </head> <body> <div class="nav"> <a class="set" href="#"><span>Homepage</span></a> <a href="#"><span>Category 1</span></a> <a href="#"><span>Classification</span></a> <a href="#"><span>It could be longer</span></a> <a href="#"><span>Welcome</span></a> <a href="#"><span>My Blog</span></a> </div> </body> </html> |