纯CSS制作中英文双语导航菜单

前端之家收集整理的这篇文章主要介绍了纯CSS制作中英文双语导航菜单前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

下面是编程之家 jb51.cc 通过网络收集整理的代码片段。编程之家小编现在分享给大家,也给大家做个参考。

网站模板开发过程中,时常有客户需要把菜单做成中英文效果,当鼠标悬浮时切换语言,今天创客云分享一款你一定喜欢的 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>

代码预览

<!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 网页设计有所帮助。

以上是编程之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。

猜你在找的HTML相关文章