473,573 Members | 3,113 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7570
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#navbar 2 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************ ***********@new s.free.fr>,
metalseb <me******@free. fr> wrote:
Lee K. Seitz wrote:
Simple. Add "border:1px solid #336699;" to your "div#navbar 2 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#navbar 2 li a:hover," "div#navbar 2 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************ ***********@new s.free.fr>,
metalseb <me******@free. fr> wrote:
Lee K. Seitz wrote:
Simple. Add "border:1px solid #336699;" to your "div#navbar 2 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#navbar 2 li a:hover," "div#navbar 2 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
4992
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 any words of wisdom? Please! :-) Here is what I have so far. <!--styles--> ul#mainNav{ font: bold 80% Verdana;
9
3330
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 vertical lists on :hover i.e. http://phoenity.com/newtedge/horizontal_nav/ But what I am looking for is a horizontal list that opens another...
9
6666
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 list: <http://css.maxdesign.com.au/index.htm>
1
6606
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 firefox, the nav bar which is a horizontal blue stripe with the links written inside it doesn't stretch the whole 800px, also how would you align the...
2
2540
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 it incorrectly. I've tried playing with the ul, li, a css but can't get this to look right in the latter 2 browsers. The site is sinaiem.org . Any...
0
3127
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 the browsers I have tested it on (IE6, IE7, Firefox, Opera and Safari). It is probably something simple, but I can't find it! Here is the CSS...
3
5082
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 easier readability. With my current code, the linked text moves on the hover state. If I remove the CSS code so that the hover state text is normal...
7
5550
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 - http://www.itsyourplate.com/thin.css As you can see from the file the menu is showing up vertically not horizontally. I copied the code directly from...
0
8017
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8201
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7777
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8063
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6413
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5290
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3731
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3731
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2203
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.