내가이 HTML이 설정하지 않으 :CSS 탐색 드롭 다운 메뉴 - 폭이
<div id="wrap">
<ul class="navbar">
<li><%= link_to('home', '/') %></li>
<li><%= link_to('about', :controller => 'about') %>
<ul class="sub-menu">
<li><%= link_to('meet & greet', :controller => 'about') %></li>
<li><%= link_to('work with me!', :controller => 'contact') %></li>
<li><%= link_to('contact', :controller => 'contact') %></li>
</ul>
</li>
<li><%= link_to('recipes', :controller => 'recipes') %>
<ul class="sub-menu">
<li><%= link_to('Breads', :controller => 'about') %></li>
<li><%= link_to('Breakfast', :controller => 'contact') %></li>
<li><%= link_to('Brownies', :controller => 'contact') %></li>
<li><%= link_to('Cakes', :controller => 'contact') %></li>
<li><%= link_to('Cookies', :controller => 'contact') %></li>
<li><%= link_to('Cupcakes', :controller => 'contact') %></li>
<li><%= link_to('Donuts', :controller => 'contact') %></li>
<li><%= link_to('Gluten Free', :controller => 'contact') %></li>
<li><%= link_to('Healthy', :controller => 'contact') %></li>
<li><%= link_to('Lunch', :controller => 'contact') %></li>
<li><%= link_to('Muffins', :controller => 'contact') %></li>
<li><%= link_to('Misc.', :controller => 'contact') %></li>
<li><%= link_to('No-Bake', :controller => 'contact') %></li>
<li><%= link_to('Pasta', :controller => 'contact') %></li>
<li><%= link_to('Pizza', :controller => 'contact') %></li>
<li><%= link_to('Savory', :controller => 'contact') %></li>
</ul>
<li><%= link_to('everyday', :controller => 'blog', :action => 'everyday') %></li>
<li><%= link_to('development', :controller => 'blog', :action => 'development') %></li>
</ul>
#wrap {
height: 50px;
margin: 0; /* Ensures there is no space between sides of the screen and the menu */
z-index: 99; /* Makes sure that your menu remains on top of other page elements */
position: relative;
}
.navbar {
height: 50px;
margin-top: 7px;
position: absolute; /* Ensures that the menu doesn’t affect other elements */
margin-left: 142px;
}
.navbar li {
height: auto;
width: 110px; /* Each menu item is 150px wide */
float: left; /* This lines up the menu items horizontally */
text-align: center; /* All text is placed in the center of the box */
list-style: none; /* Removes the default styling (bullets) for the list */
font-family: 'Muli', sans-serif;
text-transform: uppercase;
font-size: 13px;
padding: 0;
margin: 0;
background-color: white;
}
.navbar a {
padding: 10px 0; /* Adds a padding on the top and bottom so the text appears centered vertically */
text-decoration: none; /* Removes the default hyperlink styling. */
color: #686868;
display: block;
}
.navbar li:hover, .navbar li a:hover, .navbar ul li a:hover {
background-color: #7BCDC8;
color: white;
}
.navbar li ul {
display: none; /* Hides the drop-down menu */
height: auto;
margin: 0; /* Aligns drop-down box underneath the menu item */
padding: 0; /* Aligns drop-down box underneath the menu item */
}
.navbar li:hover ul {
display: block; /* Displays the drop-down box when the menu item is hovered over */
color: white;
}
.navbar li ul li {
background-color: #7BCDC8;
}
.navbar li ul li a {
border-left: 1px solid #7BCDC8;
border-right: 1px solid #7BCDC8;
border-top: 1px solid #7BCDC8;
border-bottom: 1px solid #7BCDC8;
}
.navbar li ul li a:hover {
background-color: #7BCDC8;
color: white;
}
내가 목록 항목의 너비를 제거 할 그냥 설정 padding-을 왼쪽/오른쪽으로 15px 간격으로 멀리 떨어져 있습니다. 그렇게하면 드롭 다운이 더 이상 작동하지 않습니다. 유용한 팁이 있습니까?
"더 이상 작동하지 않음"을 설명해주십시오. 또한'.navbar'가 아닌'li' 엘레멘트의 너비를 참조하고 있습니까? –
수정하십시오. navbar ul li ul li 요소가 드롭 다운됩니다. – Christina
CSS에서 (중요)을 사용하여 요소에 스타일을 적용 해 보았습니까? – eddwinpaz