Afternoon,
I have an issue with my CSS. The third dropdown is placed incorrectly and I have no solution.
Here is what I want:
Before:
http://i53.tinypic.com/2qu85z8.png
After:
http://i51.tinypic.com/241k1on.png
Here is the CSS:
ul.dropdown, ul.dropdown li, ul.dropdown ul {
list-style: none outside none;
}
ul.dropdown {
background: url("../img/nav_bg.png") no-repeat scroll left top transparent;
float: left;
padding: 0 0 3px;
position: relative;
width: 970px;
z-index: 100;
}
ul.dropdown li {
float: left;
font-size: 1.2em;
font-weight: bold;
line-height: 1.2em;
margin: 0;
padding: 0;
position: relative;
}
ul.dropdown li a {
color: #000000;
display: block;
padding: 7px 0;
}
ul.dropdown li a:hover {
color: #0971BA;
}
ul.dropdown li a span {
border-right: 1px solid #D6DBE0;
display: block;
padding: 8px 12px;
}
ul.dropdown li a.active {
color: #0971BA;
}
ul.dropdown li.drop a span {
background: url("../img/nav_icons.png") no-repeat scroll right 13px transparent;
min-height: 0;
padding: 8px 25px 8px 12px;
}
ul.dropdown li.drop:hover {
margin: 0 0 0 -1px;
text-align: left;
}
ul.dropdown li.drop a {
background: url("../img/nav_sub_bg.png") repeat-x scroll 0 -999em transparent;
}
ul.dropdown li.drop:hover a {
background: url("../img/nav_sub_bg.png") repeat-x scroll 0 0 #0653AE;
min-height: 0;
}
ul.dropdown li.drop:hover a span {
background-position: right -12px;
border: medium none;
color: #FFFFFF;
padding: 8px 26px 8px 13px;
}
ul.dropdown ul {
left: 0;
margin: 0 0 0 -1px;
overflow: hidden;
padding: 8px 0 0;
position: absolute;
top: 36px;
visibility: hidden;
width: 182px;
z-index: 102;
}
ul.dropdown li ul li {
float: none;
font-size: 12px;
text-shadow: #000 0px 1px 0px;
font-weight: bold;
min-height: 0;
padding: 0;
}
ul.dropdown li.hover, ul.dropdown li:hover {
position: relative;
z-index: 103;
}
ul.dropdown li.drop:hover ul li a {
background: url("../img/nav_sub_bg.png") repeat-x scroll 0 -54px transparent;
color: #FFFFFF;
display: block;
height: 14px;
min-height: 0;
padding: 7px 12px;
}
ul.dropdown li.drop:hover ul li a:hover {
background-position: 0 -92px;
min-height: 0;
}
ul.dropdown li.drop:hover ul li a span {
background: none repeat scroll 0 0 transparent;
display: inline;
padding: 0;
}
ul.dropdown li.drop:hover ul li.lastChild {
height: 30px;
}
ul.dropdown li.drop:hover ul li.lastChild a {
padding: 7px 12px 9px;
}
ul.dropdown li.drop:hover ul li.lastChild a {
background-position: 0 -130px;
}
ul.dropdown li.drop:hover ul li.lastChild a:hover {
background-position: 0 -168px;
}
ul.dropdown li:hover > ul {
visibility: visible;
}
ul.dropdown li.home a {
background: url("../img/nav_icons.png") no-repeat scroll 14px -36px transparent;
display: block;
min-height: 0;
}
ul.dropdown li.home a:hover {
background-position: 14px -69px;
}
ul.dropdown li.home a:active {
background-position: 14px -102px;
}
ul.dropdown li.home a span {
cursor: pointer;
display: block;
min-height: 0;
padding: 8px 19px 8px 20px;
text-indent: -999em;
}
change the left position of the second and further dropdowns from 0.. usually 100% works if there's already a width on the ul elements
ul.dropdown ul ul {left: 100%;}
which should overrule the left: 0; in this:
ul.dropdown ul {
left: 0;
margin: 0 0 0 -1px;
overflow: hidden;
padding: 8px 0 0;
position: absolute;
top: 36px;
visibility: hidden;
width: 182px;
z-index: 102;
}
NOTE you might also have to overrule (by adding to the extra rule) top: 36px; to top: 0;
Related
How me doing dropdown menu for pages and child pages on wordpress 4.0, but wp_page_menu not working, wp_list_pages('title_li=') ?> show menu but not show child pages. please help?
Try this:
ul.menu { list-style: none outside none; padding: 0; margin: 0 10px; float: left; font-size: 13px;}
ul.menu li { float: left; margin: 0; padding: 0 15px 0 0; position: relative; }
ul.menu li a { padding: 9px 5px; color: rgb(255, 255, 255); display: block; text-decoration: none; float: left; display: block;}
ul.menu li:hover { background: #A6CB1B; }
.current-cat { background: #8BBF47; }
ul.menu li span { width: 11px; height: 10px; float: left; background: url('/*url of your background or write color anme*/') -561px -78px no-repeat; margin: 11px 0 0 0;}
ul.menu li ul.children {z-index:99; list-style: none outside none; position: absolute; left: 0; top: 31px; background: none repeat scroll 0% 0% rgb(51, 51, 51); margin: 0; padding: 0; display: none; float: left; width: 170px; border-bottom: 1px solid #F8C92D;}
ul.menu li ul.children li { margin: 0; padding: 0; clear: both; width: 170px; border-top: 1px solid #F8C92D;}
html ul.menu li ul.children li a { float: left; width: 145px; background: url('images/narga-sprites.png') -578px -162px no-repeat #A6CB1B; padding-left: 20px; }
html ul.menu li ul.children li a:hover { background: url('/*url of your background or write color anme same as above*/') -578px -162px no-repeat #7BAF36; }
NOTE: This code is untested.Make sure to do necessary changes as per your needs.
I'm working on a css/html site and I have this problem: in my style.css I got two divs, one for sidebar and one for content. I would like the sidebar to be, well, at the side, but when both are present the content always goes below the sidebar, unless I put that in position:absolute. In that case I have a problem when small screens are used, 'cause they get one over the other.
I paste the code, hope you can help!
/* This is for content */
article, aside, figure, footer, header, hgroup, menu, nav, section {
display: block;
}
#modal {
position: relative;
width: 100%;
display: inline-block;
display: table;
display: table-cell;
float: none;
border: 1px solid #CCC;
box-shadow: 0 1px 5px #CCC;
border-radius: 5px;
font-family: verdana;
margin: 25px auto;
text align: center;
background-color: #f2f2f2;
overflow: auto;
}
#modal header {
background: #f1f1f1;
background-image: -webkit-linear-gradient( top, #f1f1f1, #CCC );
background-image: -ms-linear-gradient( top, #f1f1f1, #CCC );
background-image: -moz-linear-gradient( top, #f1f1f1, #CCC );
background-image: -o-linear-gradient( top, #f1f1f1, #CCC );
box-shadow: 0 1px 2px #888;
padding: 10px;
}
#modal h1 {
padding: 0;
margin: 0;
font-size: 16px;
font-weight: normal;
text-shadow: 0 1px 2px white;
color: #323232;
text-align: center;
}
#modal section {
padding-right: 10px;
padding-left: 10px;
padding-bottom: 10px;
font-size: 12px;
line-height: 175%;
color: #333;
text-align: center;
}
while this is the sidebar
/*sidebar */
#sidebar{
position: static;
margin-top: 15px;
max-width: 150px;
}
#sidebar ul,
#sidebar ul li,
#sidebar ul ul {
list-style: none;
margin: 0;
padding: 0;
border: 0;
top: 5%;
}
#sidebar ul {
position: static;
top: 90px;
z-index: 1000;
}
#sidebar ul li {
min-height: 1px;
line-height: 1em;
vertical-align: middle;
}
#sidebar ul li.hover,
#sidebar ul li:hover {
position: relative;
z-index: 599;
cursor: default;
}
#sidebar ul ul {
margin-top: 1px;
visibility: hidden;
position: absolute;
top: 1px;
left: 99%;
z-index: 598;
width: 100%;
}
#sidebar ul ul li {
float: none;
}
#sidebar ul ul ul {
top: 1px;
left: 99%;
}
#sidebar ul li:hover > ul {
visibility: visible;
}
#sidebar ul li {
float: none;
}
#sidebar ul ul li {
font-weight: normal;
}
/* Custom CSS Styles */
#sidebar {
font-family: 'Lato', sans-serif;
font-size: 18px;
width: 180px;
}
#sidebar ul a,
#sidebar ul a:link,
#sidebar ul a:visited {
display: block;
color: #000000;
text-decoration: none;
font-weight: 300;
}
#sidebar > ul {
float: none;
}
#sidebar ul {
background: #a0a0a0;
}
#sidebar > ul > li {
border-left: 3px solid #000000;
}
#sidebar > ul > li > a {
padding: 10px 20px;
}
#sidebar > ul > li:hover {
border-left: 3px solid #9b1a1c;
}
#sidebar ul li:hover > a {
color: #9b1a1c;
}
#sidebar > ul > li:hover {
background: #f6f6f6;
}
/* Sub Menu */
#sidebar ul ul a:link,
#sidebar ul ul a:visited {
font-weight: 400;
font-size: 14px;
}
#sidebar ul ul {
width: 180px;
background: none;
border-left: 20px solid transparent;
}
#sidebar ul ul a {
padding: 8px 0;
border-bottom: 1px solid #eeeeee;
}
#sidebar ul ul li {
padding: 0 20px;
background: #fff;
}
#sidebar ul ul li:last-child {
border-bottom: 3px solid #000000;
padding-bottom: 10px;
}
#sidebar ul ul li:first-child {
padding-top: 10px;
}
#sidebar ul ul li:last-child > a {
border-bottom: none;
}
#sidebar ul ul li:first-child:after {
content: '';
display: block;
width: 0;
height: 0;
position: absolute;
left: -20px;
top: 13px;
border-left: 10px solid transparent;
border-right: 10px solid #fff;
border-bottom: 10px solid transparent;
border-top: 10px solid transparent;
}
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
Despite of many efforts, I am unable to make the drop down menu of the same width as of the parent. Please help me out. Fiddle here
#menu, #menu ul {
margin: 0;
padding: 0;
list-style: none;
}
#menu {
width: 958px;
/*margin: 60px auto;*/
border: 1px solid #222;
background-color: #111;
background-image: linear-gradient(#444, #111);
box-shadow: 0 1px 1px #777;
}
#menu:before,
#menu:after {
content: "";
display: table;
}
#menu:after {
clear: both;
}
#menu {
zoom:1;
}
#menu li {
float: left;
border-right: 1px solid #222;
box-shadow: 1px 0 0 #444;
position: relative;
}
#menu a {
float: left;
padding: 11px 40px;
color: #999;
text-transform: uppercase;
text-decoration: none;
text-shadow: 0 1px 0 #000;
}
#menu li:hover > a {
color: #fafafa;
}
*html #menu li a:hover { /* IE6 only */
color: #fafafa;
}
#menu ul {
margin: 20px 0 0 0;
_margin: 0; /*IE6 only*/
opacity: 0;
visibility: hidden;
position: absolute;
top: 38px;
left: 0;
z-index: 1000000;
background: #444;
background: linear-gradient(#444, #111);
box-shadow: 0 -1px 0 rgba(255,255,255,.3);
transition: all .2s ease-in-out;
}
#menu li:hover > ul {
opacity: 1;
visibility: visible;
margin: 0;
}
#menu ul ul {
top: 0;
left: 150px;
margin: 0 0 0 20px;
_margin: 0; /*IE6 only*/
box-shadow: -1px 0 0 rgba(255,255,255,.3);
}
#menu ul li {
float: none;
display: block;
border: 0;
_line-height: 0; /*IE6 only*/
box-shadow: 0 1px 0 #111, 0 2px 0 #666;
}
#menu ul li:last-child {
box-shadow: none;
}
#menu ul a {
padding: 10px;
width: 130px;
_height: 10px; /*IE6 only*/
display: block;
white-space: nowrap;
float: none;
text-transform: none;
}
#menu ul a:hover {
background-color: #000000;
}
#menu ul li:first-child > a {
/*border-radius: 3px 3px 0 0;*/
padding: 11px 13px;
}
#menu ul li:first-child > a:after {
content: '';
position: absolute;
left: 40px;
top: -6px;
}
#menu ul ul li:first-child a:after {
left: -6px;
top: 50%;
margin-top: -6px;
border-left: 0;
}
#menu ul li:first-child a:hover:after {
border-bottom-color: #000;
}
#menu ul ul li:first-child a:hover:after {
border-right-color: #000;
border-bottom-color: transparent;
}
#menu ul li:last-child > a {
/*border-radius: 0 0 3px 3px*/;
padding: 11px 20px;
}
HTML:
<ul id="menu">
<li>About </li>
<li>Programmes
<ul>
<li>Undergraduate</li>
<li>Postgraduate</li>
</ul>
</li>
<li>Academics</li>
<li>Research</li>
<li>Facilities</li>
<li></li>
</ul>
In the dropdown menu ul element add "right: 0" (or -1px in your case to take into account the borders):
#menu ul {
margin: 20px 0 0 0;
_margin: 0; /*IE6 only*/
opacity: 0;
visibility: hidden;
position: absolute;
top: 38px;
left: 0;
right: -1px /* <-- add this */
z-index: 1000000;
background: #444;
background: linear-gradient(#444, #111);
box-shadow: 0 -1px 0 rgba(255,255,255,.3);
transition: all .2s ease-in-out;
}
Then remove the width property in the a element:
#menu ul a {
padding: 10px;
_height: 10px; /*IE6 only*/
display: block;
white-space: nowrap;
float: none;
text-transform: none;
}
This will work independently of the menu container width.
working fiddle http://jsfiddle.net/chopsticks/XLxJk/4/
#menu ul a {
padding: 10px;
width: 150px;
_height: 10px; /*IE6 only*/
display: block;
white-space: nowrap;
float: none;
text-transform: none;
}
#menu ul li:first-child > a {
padding: 11px 20px;
}
DEMO
So by positioning your dropdown menu absolutely you are removing it from the flow. This causes it to no longer size to the width of it's parent element. You'll need to explicitly set the width, set the width explicitly via js (if you want the menu items to size based on the text they contain) or figure out how to position it differently so it inherits the width.
How about this ?
Just set the width to 100% in the #menu ul, and you have a dropdown of the same size.
http://jsfiddle.net/XLxJk/3/
In most browser it works perfectly.
but in IE7, please check the screenshot, it is really messy.
the drop down menu is not in the correct position.
the drop down menu items is not link together.
the search text field is not in the correct position.
the seach submit button-why there's a "text" on top of the button..?
the rounded corner (less important anyway)
please check the menu demo here.
<style>
.header-bg {
background: url(img/header-bg.jpg) repeat-x top;
height: 420px;
}
body {
background: url(img/page-bg.jpg) repeat;
font-family: Arial, Helvetica, sans-serif;
}
.top-wrapper {
background: none;
margin: -430px auto 270px;
min-height: 150px;
padding: 10px 27px 0 27px;
width: 980px;
clear: both;
overflow: hidden;
}
.top-wrapper .top-menu {
background: #f1faf4;
border-right: 1px solid #81b030;
border-bottom: 1px solid #81b030;
border-left: 1px solid #81b030;
-moz-border-radius-bottomright: 6px;
border-bottom-right-radius: 6px;
-moz-border-radius-bottomleft: 6px;
border-bottom-left-radius: 6px;
padding: 10px 35px 8px 35px;
float: right;
}
.top-wrapper .top-menu li {
float: left;
padding: 8px 14px 10px 0;
margin: 0 14px 0 0;
border-right: 1px dotted #282828;
}
.top-wrapper .top-menu li a {
color: #282828;
font-size: 12px;
font-weight: bold;
text-decoration: none;
}
.top-wrapper .top-menu li a:hover {
text-decoration: underline;
}
.top-wrapper .top-menu li.search {
padding: 0 10px 0 0;
}
.top-wrapper .top-menu li.search input {
float: left;
border: none;
}
.top-wrapper .top-menu li.search input.search {
background: url(img/top-input-bg.png) no-repeat left;
width: 188px;
height: 34px;
font-size: 12px;
padding: 0 0 0 7px;
color: #9fa0a0;
}
.top-wrapper .top-menu li.search input.submit {
background: url(img/top-submit-bg.png) no-repeat left;
width: 27px;
height: 34px;
padding: 0;
text-indent: -9999px;
outline: none;
cursor: pointer;
}
.top-wrapper .top-menu li.fb-signin {
padding: 2px 0 0 0;
margin: 0;
border: none;
}
.top-wrapper .top-menu li.fb-signin a {
width: 90px;
height: 30px;
display: block;
outline: none;
cursor: pointer;
background: url(img/btn-fb-signin.png) no-repeat left;
text-indent: -9999px;
}
.top-wrapper .top-menu li.signedin {
padding: 2px 0 0 0;
margin: 0;
border: none;
}
.top-wrapper .top-menu li.signedin img {
display: inline-block;
margin: 0 10px 0 0;
vertical-align: top;
}
.top-wrapper .top-menu li.signedin a.menu {
display: inline-block;
margin: 10px 0 0 0;
}
/* REGULAR MENU DROPDOWN */
.top-wrapper .top-menu li ul {
display: none;
margin: 0;
padding: 10px 0 0 -50px;
margin: 0 0 0 -50px;
position: absolute;
top: 42px;
text-align: left;
width: 160px;
}
.top-wrapper .top-menu li ul li {
background: none repeat scroll 0 0 #F1FAF4;
border-bottom: 1px solid #b3c8ba;
border-right: none;
display: inline-block;
float: none;
margin: 0 0 0 -15px;
padding: 10px 0;
width: 160px;
position: relative;
z-index: 1000;
}
.top-wrapper .top-menu li ul li a {
color: #000 !important;
text-decoration: none;
padding: 0 0 0 15px;
}
.top-wrapper .top-menu li ul li a:hover {
text-decoration: underline;
}
.top-wrapper .top-menu li:hover > ul {
background: none repeat scroll 0 0 transparent;
display: block;
margin: 0 0 0 0;
padding: 10px 0 0;
}
/* USER MENU DROPDOWN */
.top-wrapper .top-menu li.signedin ul {
display: none;
margin: 0;
padding: 10px 0 0;
position: absolute;
top: 42px;
text-align: left;
width: 200px;
}
.top-wrapper .top-menu li.signedin ul li {
background: none repeat scroll 0 0 #F1FAF4;
border-bottom: 1px solid #b3c8ba;
border-right: none;
display: inline-block;
float: none;
margin: 0;
padding: 10px 0;
width: 125px;
position: relative;
z-index: 1000;
}
.top-wrapper .top-menu li ul li.first .corner-left {
background: url(img/menu-corner-left.png) no-repeat center;
width: 6px;
height: 6px;
position: absolute;
left: -6px;
top: 0;
}
.top-wrapper .top-menu li ul li.first .corner-right {
background: url(img/menu-corner-right.png) no-repeat center;
width: 6px;
height: 6px;
position: absolute;
right: -6px;
top: 0;
}
.top-wrapper .top-menu li ul li.last {
border-bottom-right-radius: 6px;
border-bottom-left-radius: 6px;
-moz-border-bottom-right-radius: 6px;
-moz-border-bottom-left-radius: 6px;
-webkit-border-bottom-right-radius: 6px;
-webkit-border-bottom-left-radius: 6px;
}
.top-wrapper .top-menu li.signedin ul li a {
color: #000 !important;
text-decoration: none;
padding: 0 0 0 10px;
}
.top-wrapper .top-menu li.signedin ul li a:hover {
text-decoration: underline;
}
.top-wrapper .top-menu li.signedin:hover > ul {
background: none repeat scroll 0 0 transparent;
display: block;
margin: 0 0 0 0;
padding: 10px 0 0;
}
/* SEARCH MENU DROPDOWN */
.top-wrapper .top-menu li.search ul {
display: none;
margin: 0;
padding: 10px 0 0;
position: absolute;
top: 42px;
text-align: left;
width: 222px;
}
.top-wrapper .top-menu li.search input.search:focus {outline: none; border: none;}
}
.top-wrapper .top-menu li.search ul li {
background: none repeat scroll 0 0 #F1FAF4;
border-bottom: 1px solid #b3c8ba;
border-right: none;
display: inline-block;
float: none;
margin: 0;
padding: 10px 0;
width: 222px;
position: relative;
z-index: 1000;
}
.top-wrapper .top-menu li.search ul li a {
color: #000 !important;
text-decoration: none;
padding: 0 0 0 15px;
}
.top-wrapper .top-menu li.search ul li a:hover {
text-decoration: underline;
}
.top-wrapper .top-menu li.search:hover > ul {
background: none repeat scroll 0 0 transparent;
display: block;
margin: 0 0 0 0;
padding: 10px 0 0;
}
</style>
ahh....
*:first-child+html .top-wrapper .top-menu li ul li
this will do the trick..
=)
This is the CSS for the dropdown menu I create, the problem is that the menu disappears as soon as I hover the children items.
It gets fixed If I set Height:30px and line-height: 30px but I do not want to adjust height. I want it to auto adjust. I can't get it to work in IE7. This is my CSS
#menu {
display: block;
width: 1000px;
height: 30px;
background: url(../images/modern/menu.png) no-repeat;
margin: 10px 0 0 0;
position: relative;
z-index: 10;
}
#menu ul {
float: left;
margin: 0 0 0 5px;
display: inline;
width: 795px;
}
#menu ul li {
position: relative;
float: left;
display: block;
position: relative;
}
#menu ul li a {
float: left;
display: block;
color: #fff;
font-weight: bold;
padding: 9px 10px 9px 10px;
background: url(../images/modern/menu_l.png) no-repeat right;
}
/* sub menu style */
#menu ul ul {
padding:0;margin:0;border:none;
float: none;
display: none;
position: absolute;
z-index: 10;
width: 190px;
top: 29px;
left: 0;
}
#menu ul ul ul {
top: 0;
left: 190px;
}
#menu ul ul li {
float: none;
display: block;
position: relative;
}
#menu ul ul li a {
padding:0;margin:0;border:none;
float: none;
display: block;
font-weight: bold;
position: static;
background: none;
color: #fff;
padding: 6px 10px 6px 10px;
background: #333;
border-bottom: 1px solid #444;
}
This fixes it but I really do not want to set height for child item:
#menu ul ul li a {
padding:0;margin:0;border:none;
float: none;
display: block;
font-weight: bold;
position: static;
background: none;
color: #fff;
padding: 6px 10px 6px 10px;
background: #333;
border-bottom: 1px solid #444;
height: 30px;
line-height: 30px;
}
Try zoom:1; to the thing you applied height:30px; to.