|
|||
CSS-Dropdown-Menü mit gleicher Breite (wie Parent)
Hi Leute,
ich habe ein Problem mit einem Dropdown-Menü, dem ich eine feste Breite zugewiesen habe, damit es so breit ist wie der Parent. Allerdings ist das nur ein Schätzwert, da ich das dynamisch halten möchte. So ist das Problem: Sobald also jemand eine andere Schrift verwendet, ist der Dropdown-Balken breiter oder schmaler und das sieht nicht schön aus. WP: Code:
<div id="obenrechts"> <nav id="nav" role="navigation" class="gross"> <?php wp_nav_menu( array('menu' => 'primary' ) ); ?> </nav> </div> Code:
#nav {display: block; float: left; margin: 0 auto; width: 100%; font-size: 0.75rem;} #nav ul, div.menu ul {list-style: none; margin: 0; padding: 0;} #nav li, div.menu li {float: left; position: relative;} #nav ul ul {display: none; position: absolute; top: 3.4rem; left: 0; float: left; width: auto; z-index: 99999;} #nav a {color: #333; display: block; padding: 0 1.1rem; text-decoration: none; font-weight: normal; background: rgba(255, 255, 255, .7); margin: 0 0 0 2px;} #nav ul li:hover > ul {display: block;} #nav li:hover > a, #nav ul ul :hover > a {color: #888; background: rgba(255, 255, 255, .9);} #nav ul ul a {background: rgba(255, 255, 255, .7); text-align: center; line-height: 1rem; width: inherit; padding: 10px 15px; height: auto; margin: 2px 0 0 2px} #nav ul li.current_page_item > a, #nav ul li.current-menu-ancestor > a, #nav ul li.current Ansehen kann man sich das testweise hier: studio-scs.de Mit width: inherit; funktioniert es natürlich nicht, da das Menü darüber ja auch keine feste Breite zugewiesen bekommen hat. Wisst ihr eine einfache Lösung dafür, ohne dass man dafür JS oder so benötigt? Vielen Dank vorab. Geändert von vega (30.10.2014 um 11:17 Uhr) |
Sponsored Links |
Sponsored Links |
|
|||
Zitat:
kein JS einsetzen möchte. Das lösche ich jetzt erst einmal. Danach meinst du, einfach nur dem ul.sub-menu li {width: 100%;} geben, korrekt? Okay, JS entfernt, aber mein ul.sub-menu li hatte ja sowieso schon die width: 100%. Das hat also nicht zur Lösung geführt. So habe ich es nun: Code:
#nav {display: block; float: left; margin: 0 auto; width: 100%;} #nav ul, div.menu ul {list-style: none; margin: 0; padding: 0;} #nav li, div.menu li {float: left; position: relative;} #nav ul ul {display: none; position: absolute; left: 0; float: left; width: auto; z-index: 99999;} #nav ul.sub-menu li {float: none; width: 100%; display: block;} #nav a {color: #333; display: block; padding: 0 1.1rem; text-decoration: none; font-weight: normal; background: rgba(255, 255, 255, .7); margin: 0 0 0 0.2rem; font-family: Dosis, Helvetica, Arial, sans-serif; font-size: 1rem;} #nav ul li:hover > ul {display: block;} #nav li:hover > a, #nav ul ul :hover > a {color: #888; background: rgba(255, 255, 255, .9);} #nav ul ul a {background: rgba(255, 255, 255, .7); text-align: center; line-height: 1rem; padding: 10px 10px; height: auto; margin: 2px 0 0 0.2rem;} #nav ul li.current_page_item > a, #nav ul li.current-menu-ancestor > a, #nav ul li.current-menu-item > a, #nav ul li.current-menu-parent > a {background: rgba(255, 255, 255, .9);} Geändert von vega (30.10.2014 um 14:42 Uhr) |
|
||||
… oder aber ich lese meinen Beitrag noch mal genauer.
Deine Klasse heißt nicht „submenu“, sondern „sub-menu“. Somit: ul.sub-menu { width: 100%; } Dennoch, auch mit der falschen Klasse wäre es klar gewesen, wo die Breite von „auto“ auf „100%“ geändert werden müsste. |
Themen-Optionen | |
Ansicht | |
|
|
Ähnliche Themen | ||||
Thema | Autor | Forum | Antworten | Letzter Beitrag |
CSS Dropdown Navigations | Cueball | CSS | 1 | 04.10.2012 05:42 |
CSS Menü verändern | Severa | CSS | 1 | 12.09.2012 01:57 |
CSS Menü | MadBall | CSS | 3 | 21.03.2010 03:04 |
DropDown Menü verschwindet | andre-ne | CSS | 2 | 18.11.2009 10:44 |
HTML Content vor Menü, CSS soll das ändern, wie? | Geldmichel | CSS | 6 | 08.12.2006 17:35 |