Fixing dropdown alignment in IE - html

I am currently working on some client work and I make use of a simple dropdown menu i built. It seems to work fine in most browsers, except for IE. Debugging has been a real pain as IE doesn't really offer much insight and I haven't been able to pin point the exact issue.
The dropdown is a div that has position: absolute and contains three <ul>'s. From what I can tell, the div is positioned alright, but the first ul is twice the width its supposed to be, with no clear reason and thus making it seem like the entire dropwdown is not alligned properly.
The dropdown can be found here: fatumdemo.platonlearning.com. Moving over the menu items in the top menu (blue) you can see the issue.
The code is very lengthy to all post here, but in case more information about the structure and CSS is needed, I'd be glad to post it.

Joey,
1) #navigation ul li --->to add position:relative property
2) #navigation ul li .dropdown -----> Put width:450px to 500px
3) #navigation ul li .dropdown ul -----> put width:160px or something higher.
Main problem reason is width and relative, when you add absolute position relative is must of the parent element and width and height are must it absolute element

The problem was with the fact that i was using elements other than li's as children of a ul. Internet Explorer apparently doesn't tolerate this behavior, unlike all the other browsers and treats the other elements as list-items, hence my dropdown being put in the wrong list-item in IE.

Related

Why is hover pushing the content down?

If you hover over the menu over on this website you see that the content is pushed down. I inherited the stylesheet from other people and it's a complete mess. Can anyone please explain to me why this hover is pushing down the content?
The menu is built as followed:
li > ul class .sub-menu > li > a class .sub_menu_item
I looked at the position and display CSS but I can't seem to find anything strange. Any help would be greatly appreciated!
add this line into your css file:
#navigation ul.sub-menu{
position:absolute;
}
The .sub-menu elements are not given a position so they remain in the document flow when they are shown. They need a position: absolute to remove them from the flow and prevent content shift.
When I check hover on first li in the 'three columns' div you can inspect the dropdown and see that it inherits the default "position: 'relative'".
You want to apply the styling "Position: 'absolute'" on the ul class="sub-menu", which will make it effectively in its own container so it can go mostly where it wants, so you have greater control of its positioning. This is unless a parent of it has the setting "position: 'relative'", which it will then follow the boundaries of that containing cell).
Heads up also - it looks like you'll need to increase the width or something for the border-radius on the right hand side of the dropdown cells if you apply position absolute.

Opacity and z-index in elements

I have a site with a dropdown menu. When the menu expands it goes behind some li that i have later on. The z-index on the li is 10 and currently the dropdown ul does not have a z-index but it has opacity:1. Tried every combination of opacities and z-indexes in the mentioned elements but i cannot make it work as expected. I want the li to be behind the dropdown ul when it expands. The li is relatively positioned (my design needs that) and has a float property. The only way i can make this work is by using z-index:1 for the li but i don't want that as it messes up with some other elements. Any ideas?
If you want to use the z-index property, we must put on the div position:absolute;, position:fixed; or position:relative;
You should maybe take a look at your positions tags,
If you don't give position value to your elements in your css, then your z-index value will not be considered by the browser.

CSS: How does setting a right margin cause the element's parent to become visible in this example?

While looking for keyboard-accessible menus, I stumbled across this question, which has as its answer a CSS drop-down menu http://jsfiddle.net/cfWpE/. It seems to use styling on the anchors in the menu rather than :hover on the <ul> items to display the submenus without any Javascript, but I can't figure out how.
Could someone who's better than me at CSS explain how this works? I'd like to try to extend this to a 3-level menu, but without understanding how it works for two levels, that's going to be difficult.
edited for clarity:
It's not actually the keyboard part that confuses me; I understand that tabbing through updates :focus on the current focus link, but the only CSS rule that seems to be applied to those elements is
ul.menu li.list a.category:hover,
ul.menu li.list a.category:focus,
ul.menu li.list a.category:active {
margin-right:1px;
background: black;
}
I don't understand how setting margin-right to 1 pixel makes the parent <li> visible.
This is an interesting Technique to achieve a dropdown menu.
The list items .list have a very high negative margin-top and a width of 250px. This places their content out of the viewport of the browser. The child anchors a.category have a positive margin-top with exact the same value, so they are visible to the user as if they were positioned normally. Now both, the a.category and the ul.submenu have a float:left applied. that's why the submenu does not appear beneath the anchor, but beside it. (But it has no margin-top, so it is still "invisible") Both elements (a.category and ul.submenu) have 125px width and fit perfectly into the parent li which has a width of 250px. Now on hover the anchor gets an additional 1px margin. This makes both elements too wide to fit into the parent container side to side and so the floated submenu breaks onto a newline and suddenly appears below the anchor - TADA:-D
I hope you could follow my explanation - if not ask please which part I need to clarify;)
Extending this to a third level is not possible - I would just go with a regular css-menu with display:block; and hide. However, you can use absolute positioning and switch the top value from a very high negative value to 0 when hovering, which would have the same effect.
Generally, i would use this with care. Some searchengines consider text that is hidden via negative margins or text-indent as blackhat SEO and may penalize one for that. Although it might be possible that Google is clever enough to recognize this as a regular dropdown-menu

Prevent space increasing between elements on hover

I have a sidebar in which there are certain li elements as an index, and on hover of each of the li elements, I have a specific image appearing 'over' the li elements (eg: position:relative;top:-25px;)
Let's say I hover over the first li element and the rollover images appears fine. However, the space between 1st and 2nd element increases while this hover is occuring. I am not able to understand why this is happening and I want to stop this from happening i.e. the image should appear over the li item without no spacing problem but only a simple rollover.
Here is a fiddle of the problem I am talking about: http://jsfiddle.net/PF35v/3/
I would use absolute positioning in this case, I usually do when dealing with images and top/side nav bars that are "glued" to one side of a screen. Alternatively, in situations in which I am set on using relative vs. absolute I use a little cheat....Here is what I changed in the above fiddle
ul#nav a:hover+img {
display: block;
position:relative;
top:-35px;
margin-bottom:-48px;
}
UPDATED FIDDLE
http://jsfiddle.net/PF35v/9/
However, if your images are all different sizes, you would need to individually set up the top and margin-bottom positioning.
adding "position:absolute;" to ul#nav a:hover#first_id+img is stopping the LIs being pushed down (tried this on Chrome). Did you try this?

Why are my floated list items stacking?

Usually, I can CSS myself out of any corner, but this Friday afternoon issue is getting to me!
Here is the problem. Mouse over the menu items (birthday, wedding, ...) and observe the dropdown.
Originally, I had these list items floating left fine. I've mucked around a lot with the CSS on the rest of the site, and since I checked them again they refused to float next to each other. They just stack up!
It works if I give them an explicit width, but I don't know from the start how wide they will be exactly (generated dynamically).
I'm looking at it on Firefox 3.6.8. The problem also occurs on Safari. I haven't tested any other browsers yet.
What am I doing wrong?
Thanks!
attempt #2
white-space:nowrap; does the trick. Set it on container - #secondary-menu ul li ul. Now submenu is one long line (tried in firebug).
Pretty handy property, I might use it one day too.
Using firebug, I changed the width of #secondary-menu ul li ul to 50em and it straightened out...
#secondary-menu ul li ul width appears to be calculated from a containing box somehow. But 100% of what, the data it contains? that doesn't make sense.
Try putting a div around the ul menu to be the position: absolute, and then the ul can resize inside it...