473,404 Members | 2,137 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,404 software developers and data experts.

Horizontal shifting on hover inside DIV

Hi folks

I want to implement a full CSS navbar on the top of my page. Basically, this
is a DIV with links on <li> tags shown in inline display.

Things are going right, but if I want to show a dashed border around the
links on hover, the li elements move horizontally. Hovering on the first
element shift the two remaining ones to the right, hovering on the middle
element shit the left one to the left, the right one to the right.

I cannot find a solution to stick them in place.

Cut & paste of the CSS and the HTML code :

div#navbar2
{
height:40px;
width:100%;
background-color:#336699;
text-align:center;
vertical-align:center;
padding-top:4px;
}
div#navbar2 ul
{
margin:0px;
padding:0px;
font-family:Verdana,Arial,Helvetica,sans-serif;
font-size:small;
color:#fff;
line-height:30px;
white-space:nowrap;
}
div#navbar2 li
{
margin-left:50px;
margin-right:50px;
border:1px solid #336699;
list-style-type:none;
display:inline;
}
div#navbar2 li a
{
text-decoration:none;
padding:7px 10px;
color:#fff
}
div#navbar2 li a:link
{
color:#fff;
}
div#navbar2 li a:visited
{
color:#ccc;
}
div#navbar2 li a:hover
{
color:#fff;
background-color:#3366ff;
border:1px dashed #ff0000;
}

<div id=navbar2>
<ul>
<li><a href="#">bouton 1</a></li>
<li><a href="#">bouton 2</a></li>
<li><a href="#">bouton 3</a></li>
</ul>
</div>

Any help for this issue would be greatly appreciated.

Regards

--
Seb
Jul 20 '05 #1
5 7549
In article <40*********************@news.free.fr>,
metalseb <me******@free.fr> wrote:
Hi folks

I want to implement a full CSS navbar on the top of my page. Basically, this
is a DIV with links on <li> tags shown in inline display.

Things are going right, but if I want to show a dashed border around the
links on hover, the li elements move horizontally. Hovering on the first
element shift the two remaining ones to the right, hovering on the middle
element shit the left one to the left, the right one to the right.

I cannot find a solution to stick them in place.


[Code snipped.]

Simple. Add "border:1px solid #336699;" to your "div#navbar2 li a"
selector. Since the border matches your background, it's the same
effect as if it was transparent (which you can't actually use as a
border color).

div#navbar2 li a
{
text-decoration:none;
padding:7px 10px;
color:#fff;
border: 1px solid #336699;
}

--
lkseitz (Lee K. Seitz) .at. hiwaay @dot@ net
"You may say I'm a dreamer, / but I'm not the only one,
I hope some day you'll join us, / And the world will live as one."
-- John Lennon, _Imagine_
Jul 20 '05 #2
Thanks a lot Lee

I was trying to do the same on the <li> style and it was not working.

Regards

--
Seb
Metal extrême, gothique et atmosphérique
http://www.metal-extreme.com
The Unholy Black Metal Songtitle-O-Matic
http://metalseb.free.fr
Jul 20 '05 #3
Thanks a lot Lee

I was trying to do the same on the <li> style and it was not working.

Regards

--
Seb
Metal extrême, gothique et atmosphérique
http://www.metal-extreme.com
The Unholy Black Metal Songtitle-O-Matic
http://metalseb.free.fr
Jul 20 '05 #4
In article <40***********************@news.free.fr>,
metalseb <me******@free.fr> wrote:
Lee K. Seitz wrote:
Simple. Add "border:1px solid #336699;" to your "div#navbar2 li a"
selector.


Thanks a lot Lee

I was trying to do the same on the <li> style and it was not working.


Keep in mind that the style always applies to the last item of the
selector. So "div#navbar2 li a:hover," "div#navbar2 li a:visited,"
etc. all style the anchor (<a>) tag, which is different (and inside)
the list item (<li>) tag. Styling the list items wouldn't be a bad
way to go (assuming you style them all instead of the anchors), except
for one little thing: IE doesn't implement ":hover" on anything but
anchor tags.

--
lkseitz (Lee K. Seitz) .at. hiwaay @dot@ net
Please don't feel the trolls.
Jul 20 '05 #5
In article <40***********************@news.free.fr>,
metalseb <me******@free.fr> wrote:
Lee K. Seitz wrote:
Simple. Add "border:1px solid #336699;" to your "div#navbar2 li a"
selector.


Thanks a lot Lee

I was trying to do the same on the <li> style and it was not working.


Keep in mind that the style always applies to the last item of the
selector. So "div#navbar2 li a:hover," "div#navbar2 li a:visited,"
etc. all style the anchor (<a>) tag, which is different (and inside)
the list item (<li>) tag. Styling the list items wouldn't be a bad
way to go (assuming you style them all instead of the anchors), except
for one little thing: IE doesn't implement ":hover" on anything but
anchor tags.

--
lkseitz (Lee K. Seitz) .at. hiwaay @dot@ net
Please don't feel the trolls.
Jul 20 '05 #6

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

Similar topics

1
by: RugbyTravis | last post by:
I want to have a list that is horizontal and each <li> has different images. I also want them to change on hover. I want the words to be below the images as well. Anyone of you styles gurus have...
9
by: Verona Busch | last post by:
Hi everybody, I am very happy to find this group. I am searching for a solution to make a horizontal list menu with submenu on hover. I found a lot of examples for horizontal lists which open...
9
by: patrick j | last post by:
Hi I've just discovered that IE 7 messes up horizontal lists. I've done a bit of searching the web but a solution has not sprung forth from this searching. Below is a url with a horizontal...
1
by: camphor | last post by:
hi, I have a single column webpage with a horizontal dropdown menu and am trying to make the nav bar fit across the page, the column is 800px, it looks ok in dreamweaver 8 but when I test it in...
2
by: dartanian | last post by:
I have a fluid horizontal navbar on my website which is formatted using floats and percentage widths to make it fluid. This looks great in WinXP Firefox, Opera, and even IE6. Safari and IE7 render...
0
by: mjohnson0321 | last post by:
I am trying to incorporate a CSS drop-down menu into a site (suckerfish menu). The menu gets lost behind the content below it, but only on one of the drop downs (News). The error occurs on all of...
3
by: stevedude | last post by:
A CSS newbie here: I've been learning CSS as I go along developing a web page. I am trying to make a horizontal menu link for a footer. On 'hover', I want the linked text to have a 'bold' font for...
7
by: milestogofromhere | last post by:
It is late so this is probably something really obvious but I am not seeing it. Can someone please help? Here is the page in question: html - http://www.itsyourplate.com/index2.php css -...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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.