这个讨论已经很好地帮助我设置了导航栏。但是现在,我的子链接之间有很大的空间,并且不与父链接对齐。
我的网站可以在这里看到
关于如何将我的子链接(洛杉矶、圣地亚哥檀香山等)与父链接(位置)对齐的任何想法?另外,如何减少子链接(洛杉矶、圣地亚哥、檀香山......)之间的空间?
这是我的 CSS 以便更快地参考。
#mainNav {
/*font-size: 1.0em; doesn't seem to do anything*/
/*height: 20px; doesn't seem to do anything*/
margin-top: -10px;
position: absolute;
right: 5%;
top: 40%;
}
/*-------------------------------*/
/*----------Below is CSS for List of Parent Links---------------------*/
#mainNav ul {
list-style-type: none;
position: relative;
display: inline-table;
}
/*----------Below is CSS for List of Location Links---------------------*/
#mainNav ul ul{
list-style: none;
display: none;
}
/*----------Below is CSS for List of Location---------------------*/
#mainNav ul li {float: left;
text-decoration: none;
margin: 0 0 0 25px;
padding-top: 0;
float: left;
width: auto;
list-style: none outside none;
font-size: 0.90em;
text-transform: uppercase;}
#mainNav ul li a {display: block; text-decoration: none;}
#mainNav ul ul {
display: none; /*if this is block, it causes all the sub links to show at once!*/
position: absolute;
width: auto;
top: 35%;
}
#mainNav ul li:hover > ul { display: block;}
#mainNav ul ul li {width: 100%;}
#mainNav li li {
float: none;
width: auto;
}