js realizes the effect of switching between Chinese and English in navigation bar

  • 2021-07-12 04:38:49
  • OfStack

Thoughts:

The height of ul is one and a half of that of li, ul {overflow: hidden}

li:hover{margin-top:-40px;}


<!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> Switch navigation bar between Chinese and English </title>
<style type="text/css">
*{padding:0; margin:0;}
li{ list-style:none; }
a{ text-decoration:none;}
.nav{ width:100%; height:40px; background:#222; margin-top:100px; overflow:hidden;}
.list{ width:1000px; height:40px; margin:0 auto;}
.list li{ float:left;}
.list li a{ display:block; transition:0.3s;}
.list b,.list i{ display:block; padding:0 30px; color:#aaa; line-height:40px; text-align:center;}
.list b{ font-weight:100}
.list i{ font-style:normal; background:#333; color:#fff;}
.list a:hover{ margin-top:-40px;}
</style>
</head>
<body>
<div class="nav">
 <ul class="list">
 <li>
  <a href="#">
  <b>Index</b>
  <i> Home page </i>
  </a>
 </li>
 <li>
  <a href="#">
  <b>course</b>
  <i> Vocational curriculum </i>
  </a>
 </li>
 <li>
  <a href="#">
  <b>study</b>
  <i> Employment learning </i>
  </a>
 </li>
 <li>
  <a href="#">
  <b>BBS</b>
  <i> Community </i>
  </a>
 </li>
 <li>
  <a href="#">
  <b>JiKe+</b>
  <i> Discover +</i>
  </a>
 </li>
 </ul>
</div>
</body>
</html>

Related articles: