我想在不使用父菜单li的宽度的情况下将下拉菜单居中对齐。
CSS:
ul{list-style: none;}
li{display: block; float:left; height: 20px; background: #999999; margin: 10px; position:relative;}
li span{height: 100px; width: 100px; background:#6699FF;position:absolute; left:-50%; display:none;}
li:hover span{ display: block;}
HTML:
<ul>
<li>Sample Content <span></span></li>
<li>Sample Content Sample Content<span></span></li>
<li>Sample Content<span></span></li>
<li>Sample ContentSample ContentSample Content<span></span></li>
</ul>
示例:http: //jsfiddle.net/y5nh8/