2015-04-07 42 views
0

希望有人可以請幫助!我在商店下面創建了一個下拉菜單,我無法弄清楚1.)爲什麼我無法調整容納子項目的容器的大小,以及2.)如何將子項目移到左側,在商店下方對齊BTN。這讓我瘋狂!!非常感謝您考慮看看CSS下拉菜單將無法正確定位

/* Generated by Font Squirrel (http://www.fontsquirrel.com) on September 4, 2014 */ 
 
@font-face { 
 
    font-family: 'revolution'; 
 
    src: url('../fonts/revolution/revolution-webfont.eot'); 
 
    src: url('../fonts/revolution/revolution-webfont.eot?#iefix') format('embedded-opentype'), 
 
     url('../fonts/revolution/revolution-webfont.woff') format('woff'), 
 
     url('../fonts/revolution/revolution-webfont.ttf') format('truetype'), 
 
     url('../fonts/revolution/revolution-webfont.svg#revolutionrevolution') format('svg'); 
 
    font-weight: normal; 
 
    font-style: normal; 
 
} 
 

 

 

 
/************************* 
 
Start Styling 
 
*************************/ 
 

 
body#pages { 
 
\t margin: 0 auto; 
 
\t background-image: url('../images/pages_bg.jpg'); 
 
\t background-repeat: repeat-x; 
 
} 
 

 

 
#wrapper_2 { 
 
\t width: 1024px; 
 
\t background-color: #fff; 
 
\t margin: auto; 
 
\t 
 
} 
 

 
/************************* 
 
SHOP MENU 
 
*************************/ 
 
#shop_menu { 
 
    position: absolute; 
 
    width: 800px; 
 
    margin-left: -90px; 
 
    margin-top: 42px; 
 
} 
 

 
#shop_menu ul{ 
 
    padding-left: 235px; 
 
    padding-top: 15px; 
 
} 
 

 
#shop_menu li { 
 
    text-align: center; 
 
    display: inline-block; 
 
    padding-right: 3px; 
 
} 
 

 
#shop_menu a{ 
 
    font-family: 'revolution'; 
 
    font-size: 10pt; 
 
    color: #0c5066; /*Teal Blue*/ 
 
    text-decoration: none; 
 
} 
 

 
#shop_menu a:hover{ 
 
    color: #d8512b; /*Orange Red*/ 
 
    
 
} 
 

 
/*----- DROP DOWN -----*/ 
 

 
#dropdown { 
 
    position: relative; 
 
} 
 

 
.drop-nav { 
 
    position: absolute; 
 
    display: none; 
 
} 
 
.drop-nav li { 
 
    border-bottom: 1px solid #000; 
 
} 
 
#dropdown:hover > .drop-nav { 
 
    display: block; 
 
    background-color: #888; 
 
    
 
}
<!DOCTYPE html> 
 
<html> 
 
\t <head> 
 
\t \t <title>Product Page - SHOP</title> 
 
\t \t <link rel="stylesheet" href="css/stylesTEST.css" /> 
 
\t \t </head> 
 

 
<body id="pages"> 
 

 
\t \t <div id="wrapper_2"> 
 

 
     <!--MENU --> 
 
\t \t \t <div id="shop_menu"> 
 
\t \t \t \t <ul> 
 
\t \t \t \t \t <li><a href="mockup.html">Home</a></li> 
 
\t \t \t \t \t <li>&#124;</li> 
 
\t \t \t \t \t <li><a href="#">Mission</a></li> 
 
\t \t \t \t \t <li>&#124;</li> 
 
\t \t \t \t <!--DROP DOWN --> \t 
 
\t \t \t \t \t <li id="dropdown"><a href="shop.html">Shop</a> 
 
\t \t \t \t \t \t <ul class="drop-nav"> 
 
\t \t \t \t \t \t \t <li><a href="#">Womens</a></li> 
 
\t \t \t \t \t \t \t <li><a href="#">Mens</a></li> 
 
\t \t \t \t \t \t \t <li><a href="#">Womens Plus</a></li> 
 
\t \t \t \t \t \t \t <li><a href="#">Mens Plus</a></li> 
 
\t \t \t \t \t \t \t <li><a href="#">Prints</a></li> 
 
\t \t \t \t \t \t </ul> 
 
\t \t \t \t \t </li> 
 
\t \t \t \t <!--END DROP DOWN --> \t \t 
 
\t \t \t \t \t <li>&#124;</li> 
 
\t \t \t \t \t <li><a href="#">Partner</a></li> 
 
\t \t \t \t \t <li>&#124;</li> 
 
\t \t \t \t \t <li><a href="#">Contact</a></li> 
 
\t \t \t \t \t <li>&#124;</li> 
 
\t \t \t \t \t <li><a href="#">FAQ</a></li> 
 
\t \t \t \t \t <li>&#124;</li> 
 
\t \t \t \t \t <li><a href="#" style="word-spacing:-1px">Past Campaigns</a>      </li> 
 
\t \t \t \t </ul> 
 
\t \t \t </div> 
 
\t \t \t <!--</div>--> 
 
\t \t \t <!-- END TOP NAV --> 
 

 
\t \t </div> 
 
</body>

回答

0

你有一個CSS規則爲所有的UI元素有填充左的235px。所以你的子菜單ul會相應地變寬。此外,由於瀏覽器,ul元素具有默認填充。將該特定的填充設置爲0,然後撥入它的口味。

更新:我已經先行一步,並添加CSS來只是給ul.drop-NAV填充:0

/* Generated by Font Squirrel (http://www.fontsquirrel.com) on September 4, 2014 */ 
 
@font-face { 
 
    font-family: 'revolution'; 
 
    src: url('../fonts/revolution/revolution-webfont.eot'); 
 
    src: url('../fonts/revolution/revolution-webfont.eot?#iefix') format('embedded-opentype'), 
 
     url('../fonts/revolution/revolution-webfont.woff') format('woff'), 
 
     url('../fonts/revolution/revolution-webfont.ttf') format('truetype'), 
 
     url('../fonts/revolution/revolution-webfont.svg#revolutionrevolution') format('svg'); 
 
    font-weight: normal; 
 
    font-style: normal; 
 
} 
 

 

 

 
/************************* 
 
Start Styling 
 
*************************/ 
 

 
body#pages { 
 
\t margin: 0 auto; 
 
\t background-image: url('../images/pages_bg.jpg'); 
 
\t background-repeat: repeat-x; 
 
} 
 

 

 
#wrapper_2 { 
 
\t width: 1024px; 
 
\t background-color: #fff; 
 
\t margin: auto; 
 
\t 
 
} 
 

 
/************************* 
 
SHOP MENU 
 
*************************/ 
 
#shop_menu { 
 
    position: absolute; 
 
    width: 800px; 
 
    margin-left: -90px; 
 
    margin-top: 42px; 
 
} 
 

 
#shop_menu ul{ 
 
    padding-left: 235px; 
 
    padding-top: 15px; 
 
} 
 

 
#shop_menu li { 
 
    text-align: center; 
 
    display: inline-block; 
 
    padding-right: 3px; 
 
} 
 

 
#shop_menu a{ 
 
    font-family: 'revolution'; 
 
    font-size: 10pt; 
 
    color: #0c5066; /*Teal Blue*/ 
 
    text-decoration: none; 
 
} 
 

 
#shop_menu a:hover{ 
 
    color: #d8512b; /*Orange Red*/ 
 
    
 
} 
 

 
/*----- DROP DOWN -----*/ 
 

 
#dropdown { 
 
    position: relative; 
 
} 
 

 
.drop-nav { 
 
    position: absolute; 
 
    display: none; 
 
} 
 
.drop-nav li { 
 
    border-bottom: 1px solid #000; 
 
} 
 
#dropdown:hover > .drop-nav { 
 
    display: block; 
 
    background-color: #888; 
 
    
 
} 
 

 
/* SET DROPDOWN .drop-nav UL PADDING TO 0 */ 
 
#dropdown ul.drop-nav { 
 
    padding: 0; 
 
}
<body id="pages"> 
 

 
\t \t <div id="wrapper_2"> 
 

 
     <!--MENU --> 
 
\t \t \t <div id="shop_menu"> 
 
\t \t \t \t <ul> 
 
\t \t \t \t \t <li><a href="mockup.html">Home</a></li> 
 
\t \t \t \t \t <li>&#124;</li> 
 
\t \t \t \t \t <li><a href="#">Mission</a></li> 
 
\t \t \t \t \t <li>&#124;</li> 
 
\t \t \t \t <!--DROP DOWN --> \t 
 
\t \t \t \t \t <li id="dropdown"><a href="shop.html">Shop</a> 
 
\t \t \t \t \t \t <ul class="drop-nav"> 
 
\t \t \t \t \t \t \t <li><a href="#">Womens</a></li> 
 
\t \t \t \t \t \t \t <li><a href="#">Mens</a></li> 
 
\t \t \t \t \t \t \t <li><a href="#">Womens Plus</a></li> 
 
\t \t \t \t \t \t \t <li><a href="#">Mens Plus</a></li> 
 
\t \t \t \t \t \t \t <li><a href="#">Prints</a></li> 
 
\t \t \t \t \t \t </ul> 
 
\t \t \t \t \t </li> 
 
\t \t \t \t <!--END DROP DOWN --> \t \t 
 
\t \t \t \t \t <li>&#124;</li> 
 
\t \t \t \t \t <li><a href="#">Partner</a></li> 
 
\t \t \t \t \t <li>&#124;</li> 
 
\t \t \t \t \t <li><a href="#">Contact</a></li> 
 
\t \t \t \t \t <li>&#124;</li> 
 
\t \t \t \t \t <li><a href="#">FAQ</a></li> 
 
\t \t \t \t \t <li>&#124;</li> 
 
\t \t \t \t \t <li><a href="#" style="word-spacing:-1px">Past Campaigns</a>      </li> 
 
\t \t \t \t </ul> 
 
\t \t \t </div> 
 
\t \t \t <!--</div>--> 
 
\t \t \t <!-- END TOP NAV --> 
 

 
\t \t </div> 
 
</body>

+0

謝謝!我希望這是一個「呃」類的東西:) – Courtney

+0

NP - 有很多隱藏的HTML和CSS'陷阱',你只需要沿途拾取。如果這有用,請投我一票。 –