473,405 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

List Styling

Hello,

I am creating a simple navigation bar using a list.
My anchor tags inside each list item have a background and margin. The
problem is they are overlapping.
I then added to the li tag margin-top: 20px.
The problem is that the bottom background of the last element
disappears.

I think I might doing something wrong on my styling because when I fix
something, something else gets wrong.

Could someone, please, help me out?

HTML:

<ul id="wmNavigation" class="Bar">
<li>
<a title="Page1" href="http://www.name.com/page1">Page1</a>
</li>
<li>
<a title="Page2" href="http://www.name.com/page1">Page2</a>
</li>
<li>
<a title="Page3" href="http://www.name.com/page1">Page3</a>
</li>
<li>
<a title="Page4" href="http://www.name.com/page1">Page4</a>
</li>
</ul>

CSS:

ul.Bar {}

ul.Bar li
{
font: normal 1.2em Verdana, Geneva, sans-serif;
letter-spacing: 0.1em;
margin-top: 20px;
}

ul.Bar li a
{
background-color: #202020;
color: #E2E2E2;
padding: 4px 10px 6px 12px;
text-decoration: none;
}

ul.Bar li a:link , ul.Bar li a:visited {}
ul.Bar li a:hover, ul.Bar li a:active, ul.Bar li a:focus
{
background-color: #303030;
}

Thanks,
Miguel
Jun 27 '08 #1
3 1724
On 13 May, 09:23, shapper <mdmo...@gmail.comwrote:
My anchor tags inside each list item have a background and margin. The
problem is they are overlapping.
Post a URL not a fragment.

In particular, we don't know what doctype declaration you're using, so
we don't know if IE is in Quirks or Standards mode. That will make a
difference to many issues about box sizing.
I then added to the li tag margin-top: 20px.
When fiddling with lists, always set _all_ the margins and padding on
both <ul& <li>. This avoids inconsistencies between browser default
stylesheets (some use padding to control lists, some use margin).
<li>
<a title="Page1" href="http://www.name.com/page1">Page1</a>
</li>
is better coded like this:

<li><a title="Page1"
href="http://www.name.com/page1"
>Page1</a></li>
Avoid the whitespace between tags here, as IE is sensitive to it.
Whitespace (including linebreaks) around the attributes inside the
start tag is OK.
Jun 27 '08 #2
On 2008-05-13, shapper <md*****@gmail.comwrote:
Hello,

I am creating a simple navigation bar using a list.
My anchor tags inside each list item have a background and margin. The
problem is they are overlapping.
I then added to the li tag margin-top: 20px.
The problem is that the bottom background of the last element
disappears.

I think I might doing something wrong on my styling because when I fix
something, something else gets wrong.

Could someone, please, help me out?
Put the background colour on the LI instead of on the A inside it.

The LIs don't overlap (this is defined clearly by the spec), but the top
and bottom edges of inline boxes aren't (they just depend on the font in
some way).

That should fix the original problem.

I don't know what you mean about the bottom background of the last
element disappearing. I tried your example and it seemed to be OK.

[...]
>
ul.Bar {}

ul.Bar li
{
font: normal 1.2em Verdana, Geneva, sans-serif;
letter-spacing: 0.1em;
margin-top: 20px;
background-color: #202020;
^^^^^^^^^^^^^^^^^^^^^^^^^^ <----- to here
}

ul.Bar li a
{
[background-color: #202020;] <----- move this up
Jun 27 '08 #3
On May 14, 10:25 pm, Ben C <spams...@spam.eggswrote:
On 2008-05-13, shapper <mdmo...@gmail.comwrote:
Hello,
I am creating a simple navigation bar using a list.
My anchor tags inside each list item have a background and margin. The
problem is they are overlapping.
I then added to the li tag margin-top: 20px.
The problem is that the bottom background of the last element
disappears.
I think I might doing something wrong on my styling because when I fix
something, something else gets wrong.
Could someone, please, help me out?

Put the background colour on the LI instead of on the A inside it.

The LIs don't overlap (this is defined clearly by the spec), but the top
and bottom edges of inline boxes aren't (they just depend on the font in
some way).

That should fix the original problem.

I don't know what you mean about the bottom background of the last
element disappearing. I tried your example and it seemed to be OK.

[...]
ul.Bar {}
ul.Bar li
{
font: normal 1.2em Verdana, Geneva, sans-serif;
letter-spacing: 0.1em;
margin-top: 20px;

background-color: #202020;
^^^^^^^^^^^^^^^^^^^^^^^^^^ <----- to here
}
ul.Bar li a
{

[background-color: #202020;] <----- move this up
Thank You Ben!
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Peter Collinson | last post by:
Hi... Is there any way to style a List Item a different color and size than the <LI> in an Ordered List? I'd like a red super-script number and a dark blue text in a page's footnotes. And...
3
by: mp | last post by:
I'm trying to build my first site (learning how to code by hand) using XHTML and CSS. I've done a lot of reading but I can't figure out what's going on here. I'm trying to generate tabs for a...
11
by: skeeterbug | last post by:
not sure what i'm doing developing on xmas... but i guess we all have our own demons! -lol- i'm using the following css to style my horizontal menu... /* STYLE HORIZONTAL MENU */ #hmenu...
10
by: matt_randle | last post by:
Hi, I have a problem styling a definition list. If you look at http://68.178.211.60/MattRandle/Guides/Plants/MarginalsNZ.htm you will see the effect I am trying to achieve. If, however,...
5
by: simplico | last post by:
I'm creating an unordered list that fits in a defined width on the left side of the page. It works fine in FF but IE is another story. Here is a watered-down version of the code: <html>...
3
by: Momomo | last post by:
Hi, I am having a problem with a control which is caused by a style on the page which I am not able to trace. If I use the control in a page without any styling it looks ok. Is there a way to...
5
by: Roy Smith | last post by:
Be kind to me, I'm a CSS newbie... I've been playing with drupal, building a web site (hyc-test.org). I started with the "sky" theme, but didn't like the way it rendered list items in menus. ...
40
by: Jukka K. Korpela | last post by:
My basic style sheet has a distinctive background and border for forms, to make the structure clearer and to make it visually evident what belongs to a form. However, as people complained that...
7
by: Jeff | last post by:
What's the current wisdom on styling lists for navigation. What I'd like is for: links and background colors to be 100% of the width. multi-line OK (ie links will wrap). Padding OK. Same width...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.