网站模板开发过程中,时常有客户需要把菜单做成中英文效果,当鼠标悬浮时切换语言,今天创客云分享一款你一定喜欢的 CSS 中英文双语菜单教程,此教程支持鼠标悬浮特效,您可以先运行一下看效果,绝对会另你满意。用到了一个背景图片,请自行下载。
代码如下:
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta name="Keywords" content="bilingual menu,中英文双语菜单" />
- <meta http-equiv="Description" content="完全用CSS实现的中英文双语导航菜单" />
- <meta content="all" name="robots" />
- <meta http-equiv="pragma" content="no-cache" />
- <meta name="author" content="forestgan" />
- <meta name="copyright" content="forestgan" />
- <title>完全用CSS实现的中英文双语导航菜单</title>
- <style type="text/css">
- a{
- color: #FFFF99;
- text-decoration: none;
- }
- a:hover{
- color: #FFFFFF;
- text-decoration: underline;
- }
- #nav{
- padding: 10px 10px 0;
- font-size: 12px;
- font-weight: bold;
- margin: 1em 0 0;
- list-style:none;
- }
- #nav li{
- float: left;
- margin-right: 1px;
- }
- .bi{
- position: relative;
- z-index: 0;
- }
- .bi:hover{
- z-index: 99;
- }
- .bi:hover span{
- visibility: visible;
- top: 0;
- left: 0;
- cursor: pointer;
- }
- .bi span{
- position: absolute;
- left: -999em;
- visibility: hidden;
- }
- #nav li a,.bi:hover span{
- line-height: 20px;
- text-decoration: none;
- background: #DDDDDD;
- color: #666666;
- display: block;
- width: 80px;
- text-align: center;
- }
- #nav li a:hover,.bi:hover span{
- color: #FFFFFF;
- background: #DC4E1B;
- }
- .bi:hover span{
- padding-top: 2px;
- }
- #navbar{
- background: #DC4E1B;
- height: 8px;
- overflow: hidden;
- clear: both;
- }
- </style>
- <link href="../css/main.css" rel="stylesheet" type="text/css" />
- </head>
- <body>
- <div id="top">
- <ul id="nav">
- <li><a class="bi" href="index.html">Home<span>首 页</span></a></li>
- <li><a class="bi" href="about.html">About us<span>关于我们</span></a></li>
- <li><a class="bi" href="products.html">Products<span>产品展示</span></a></li>
- <li><a class="bi" href="services.html">Services<span>售后服务</span></a></li>
- <li><a class="bi" href="contact.html">Contact<span>联系我们</span></a></li>
- </ul>
- <div id="navbar"></div>
- </div>
- </body>
- </html>
这是一个完全用 CSS 实现的中英文双语导航菜单,无脚本和图片,初始时,菜单语言是英文,当鼠标悬停在菜单上时,其变成中文,当然你也可以反过来做,以上就是完全用 CSS 实现的中英文双语导航菜单全部内容,希望本文所述对大家的 css 网页设计有所帮助。