我刚刚测试了我的代码。它适用于Chrome和Mozilla。但不是在IE 8中。
inline-block
显示问题:
见这里: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>
答案 0 :(得分: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;
}
<强>错误强>