Padding being ignored by UL element - html

I'm having some real trouble with CSS here... it's very odd.
I have a UL element wrapped within a Nav tag. I'm trying to apply some padding to the individual links and for some reason the padding isn't moving the element down and expanding the container as a result.
Here's a screenshot of what's happening:
As you can see, the padding is being noticed by the browser, but it's just overlapping with the element above (which is being floated). I can't find a way to push it down, or at the very least make the container expand to hold it properly.
For reference, I'm using the Skeleton responsive boilerplate as a base.
Here's a link to it live: http://richardsonweb.co.uk/

Try display:inline-block; on your li elements

Related

ul padding not applying next to a floating img

I have a very basic CSS problem.
I have a floating image in my top-left corner with a margin-right. The content is made of paragraphs and lists with bullets. I want my lists to have a padding-left for more visibility and my bullets appear in "list-style-position: outside" (text must be aligned).
My problem is, when a list is displayed next to my floating image, ul padding is not applying.
Here is an annotated screenshot for your comprehension :
This kind of behavior happens with FF and Chrome. With IE, it is worse because the bullets appear at the very left of the floating image...
Edit : css property "ul{overflow: hidden;}" is not an option because I want to avoid this :
I'm sorry I can't show you a piece of code because it is a Drupal website and the content of the node is generated by wysiwyg module and written by webmaster and editors. I have no access to the generated structure. The content is not fixed and lists could appear everywhere in the text.
This Fiddle represents well my situation: http://jsfiddle.net/34Cuf/
I think you have to get rid of this:
list-style-position: outside
This is putting your bullets points outside of padding. In the box model, anything outside the border box collapses during a float.
Lists have initial left padding on them (so there is enough space to show the bullet) so unless you give the ul a padding that is greater than this initial value, your list will actually move left instead of right.
Have a look at this example
To make your ul behave properly next to a floated element you just need to float it too: Example
Padding won't apply to list at right of floating div, because it stays behind floating div.
It doesn't count from after div, it still counting from left as ul after floating div.
It happens because the div "floats" with text.
To understand it better, play it ul li padding in my example in fiddle
See that a put a little margin in floating div to you see that the content of ul extends form the left margin behind floating div.
You'll have to apply a bigger right margin to the floating div.

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?

How to auto space list elements within a div

I am working on a website that has these tabs at the top which I need to have automatically spaced inside a div. The reason for this, is that the div below it has a border that needs to line up with the borders on the tabs. See my jsfiddle below for what I'm talking about. I currently have them all spaced correctly, but the nature of this site is that the words in the tabs will change, making my spacing incorrect. How can I automatically space them inside my div so I don't have to tinker with all the individual padding to make them line up with the div below?
http://jsfiddle.net/g7c5X/
Should be able to achieve it by adding to your CSS something like this:
#navMenu ul {display:table; width:100%}
#navMenu li {display:table-cell}
I think older versions of IE may ignore the display type can't remember which. The other option would be some javascript to calculate the margins.

ul based html menu with css spilling into multiple lines

So essentially I have a horizontal menu using ul and li elements styled with CSS which has a fixed height attribute for the ul but since the number of li elements are too many they are spilling over into multiple lines ...since the height of the ul is fixed, the li elements appear on the next line just fine but they are outside of the 'block' of the ul...so any further html content that appears starts showing inline with the li elments on the 2nd line?
I hope I have been able to describe the problem. I wish this was a publicly accessible site, for the CSS gurus to help with using firebug or web inspector.
use min-height on your UL, not height
use float:left on your LIs
use display:block on your A tags and put all other styling on the A tags. (DO NO STYLE THE LI TAGS OTHER THAN FLOAT:LEFT)
you can expand the width of the
container tag holding the ul, you do not have enough width for all the list elements
if you can not enlarge the container try to cut down the width of the li's, using less padding and margin in between them.
you can all so use a min-width property to bee sure that they will have enough space