1

我刚刚测试了我的代码。它在 Chrome 和 Mozilla 上运行良好。但不是在 IE 8 中。

显示问题inline-block

  • 第三块:内容不垂直对齐
  • 第 5 个框:没有出现悬停子菜单。

见这里:http: //jsfiddle.net/evNjH/

    <style type="text/css">

html, body {
  margin: 0;
  padding: 0;
}

#navcontainer { padding: 0 5 20px 10px; }


ul#navlist {
  font-family: sans-serif;
  margin-left: 0;
  padding: 0;
}

ul#navlist li
{
  padding: 10px 5px 10px 5px;
  background-color: #EF634A;
}
ul#navlist > li
{
  height:38px; 
  line-height:38px;
}
ul#navlist li:hover
{
  color: #ffff00;
  background-color: #3E748A;
}
ul#navlist a
{
  font-weight: bold;
  text-decoration: none;
  display: inline-block;
  line-height:1.1;
  vertical-align: middle;
}


ul#navlist ul, ul#navlist li
{
  padding: 0 8px;
  margin: 0 8px;
  list-style-type: none;
  box-shadow: 8px 8px 12px #aaa;
}

ul#navlist > li:first-child {
  margin-left: 0;
}

ul#navlist li { float: left; 
}

ul#navlist li a
{
  color: #ffffff;

  //padding:10px;

  /*border: 1px #ffffff outset;
  height: 40px;*/ 
}


ul#navlist li:active
{
  color: #cccccc;
  background-color: #3E748A;
  border: 1px #ffffff inset;
  box-shadow: none;
}

ul#subnavlist { display: none; }
ul#subnavlist li { float: none;line-height:normal; }

ul#subnavlist li a
{
  padding: 0px;
  margin: 0px;
  height: 14px;
}

ul#navlist li:hover ul#subnavlist
{
  display: block;
  //display: inline-block;
  //display: table-cell;

  position: absolute;
  font-size: 8pt;
  padding-top: 5px;
  box-shadow: none;
}

ul#navlist li:hover ul#subnavlist li a
{
  display: block;
  width : 360;
  height : 100;
  border: none;
  padding: 2px;
}

ul#navlist li:hover ul#subnavlist li a:before { content: " >> "; }

a.white:link {color: #fff;}
a.white:active {color: #fff;}
a.white:visited {color: #fff;}
a.white:hover {color: #fff;}

</style>

和html

<div id="navcontainer">
<ul id="navlist">
<li><a href="obs-geostrategique-sport1.php?cat=2">ACTUALITÉS</a></li>
<li><a href="obs-geostrategique-sport1.php?cat=5">ANALYSE</a></li>
<li><a href="obs-geostrategique-sport1.php?cat=1">PROGRAMME EUROPÉEN DE LUTTE <br>CONTRE LE TRUCAGE DE MATCHS</a></li>
<li><a href="obs-geostrategique-sport1.php?cat=3">COMMUNIQUÉ</a></li>

<li><a href="#">THEMATIQUES</a> 
<ul id="subnavlist">
    <li id="subactive"> <a href="obs-geostrategique-sport1.php?cat=4&id=1">Lutte contre la corruption</a></li>
    <li><a href="obs-geostrategique-sport1.php?cat=4&id=2">Evènements sportifs </a></li>
    <li><a href="obs-geostrategique-sport1.php?cat=4&id=3">Bonne gouvernance du sport</a></li>
    <li><a href="obs-geostrategique-sport1.php?cat=4&id=4">Economie du sport</a></li>
    <li><a href="obs-geostrategique-sport1.php?cat=4&id=5">Lutte contre le dopage</a></li>
    <li><a href="obs-geostrategique-sport1.php?cat=4&id=7">Lutte pour l'intégrité dans le sport</a></li>
</ul>
</li>
</ul>
</div> 
4

1 回答 1

0

你在css中有一些错误,试试

html, body {
    margin: 0;
    padding: 0;
}
#navcontainer {
    padding: 0 5px 20px 10px;
}
ul#navlist {
    font-family: sans-serif;
    margin-left: 0;
    padding: 0;
}
ul#navlist li {
    padding: 10px 5px 10px 5px;
    background-color: #EF634A;
}
ul#navlist > li {
    height:38px;
    line-height:38px;
}
ul#navlist li:hover {
    color: #ffff00;
    background-color: #3E748A;
}
ul#navlist a {
    font-weight: bold;
    text-decoration: none;
    display: inline-block;
    line-height:1.1;
    vertical-align: middle;
}
ul#navlist ul, ul#navlist li {
    padding: 0 8px;
    margin: 0 8px;
    list-style-type: none;
    box-shadow: 8px 8px 12px #aaa;
}
ul#navlist > li:first-child {
    margin-left: 0;
}
ul#navlist li {
    float: left;
}
ul#navlist li a {
    color: #ffffff;
}
ul#navlist li:active {
    color: #cccccc;
    background-color: #3E748A;
    border: 1px #ffffff inset;
    box-shadow: none;
}
ul#subnavlist {
    display: none;
}
ul#subnavlist li {
    float: none;
    line-height:normal;
}
ul#subnavlist li a {
    padding: 0px;
    margin: 0px;
    height: 14px;
}
ul#navlist li:hover ul#subnavlist {
    display: block;
    position: absolute;
    font-size: 8pt;
    padding-top: 5px;
    box-shadow: none;
}
ul#navlist li:hover ul#subnavlist li a {
    display: block;
    width : 360;
    height : 100;
    border: none;
    padding: 2px;
}
ul#navlist li:hover ul#subnavlist li a:before {
    content:" >> ";
}
a.white:link {
    color: #fff;
}
a.white:active {
    color: #fff;
}
a.white:visited {
    color: #fff;
}
a.white:hover {
    color: #fff;
}

错误

  • 6 #navcontainer padding 只有0可以是长度。你必须在你的号码后面加上一个单位:0 5 20px 10px
  • 46 ul#navlist li 解析错误 //padding:10px;
  • 70 ul#navlist li:hover ul#subnavlist Parse Error //display: inline-block;
  • 71 ul#navlist li:hover ul#subnavlist 解析错误 //display: table-cell;
于 2013-08-29T13:42:05.743 回答