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

Div id hyperlink help - div widths?

okay, im really not sure what to do here, as I've done the same thing before and it's worked perfectly but now ive tried to do the same thing again for another website and it's just not working...

okay, heres the problem:

i have:

[html]<!--site related navigation-->
<div id="mainnav">
<div id="title">
.site&nbsp;
</div>
<a href="">Home</a><br />
<a href="">Staff</a><br />
<a href="">Affiliates</a><br />
<a href="">Affiliation</a><br />
<a href="">Link to Us</a><br />
<a href="">Site History</a><br />
<a href="">Past Layouts</a><br />
<a href="">About</a><br />
</div>[/html]

And in my CSS file i have:

Expand|Select|Wrap|Line Numbers
  1. #mainnav a
  2. {
  3. width: 100%;
  4. background-color: #583D21;
  5. text-align:right;
  6. text-decoration:none;
  7. color: #CCCC99;
  8. }
  9. #mainnav a:link
  10. {
  11. width: 100%;
  12. text-align:right;
  13. }
  14. #mainnav a:hover
  15. {
  16. width: 100%;
  17. background-color: #000000;
  18. text-align:left;
  19. color: #FFFFFF;
  20. }
  21. #mainnav a:visited
  22. {
  23. width: 100%;
  24. background-color: #583D21;
  25. text-align:right;
  26. }
Now this is meant to control the links in the "mainnav" div, right? and to some extent it does, with the exception of width. All of the background properties are fine, except the background does not stretch to 100% of the div width and just stays as long as the word it is the background to.
Just so you know the "mainnav" div is 200px wide so the link background should be 200px wide.

sorry if thats a bit hard to understand, this is my first post and im not really sure how to explain it.
is there something im missing? can anybody help me?
Oct 1 '07 #1
3 2638
drhowarddrfine
7,435 Expert 4TB
<a> is an 'inline' element, meaning it is just like text in a paragraph and cannot be resized. If you want to control the width, in your css, add 'display:block' which makes it, obviously, block level, just like the div.
Oct 1 '07 #2
<a> is an 'inline' element, meaning it is just like text in a paragraph and cannot be resized. If you want to control the width, in your css, add 'display:block' which makes it, obviously, block level, just like the div.
hmm, thanks that has helped, but what i don't understand is how i managed to do it before without having to do anything like that. o well, thanks for your help though.

Now i just need to figure out how to getthe links directly underneath eachother becuase now ive put the 'display:block' each link it spaced out as if you've put an extra "<br />" in the code.
Oct 1 '07 #3
drhowarddrfine
7,435 Expert 4TB
Remove the current <br>
Oct 1 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Lars G. Svensson | last post by:
As a regular ciwas reader, I learned that fixed-pixel designs are evil, so for the newly created site http://www.ddc-deutsch.de (in German, still very much under construction) I arranged the...
3
by: Steve Sabljak | last post by:
I seem to having a little trouble getting a table to display correctly in both msie and firefox. I want to set the table and column widths in pixels, and have some cell padding too. The table...
0
by: TJ Talluto | last post by:
<facts> I have a "month calendar" that always displays exactly 42 days... and alongside is a vertical box that displays the detail (form fields) of any particular select event that appears on the...
1
by: Badboy36 | last post by:
Hello user from googlegroups, i made a microsoft access database with front and backend. i created the backend in microsoft access97. for the frontend i made two versions (one for microsoft...
0
by: Ryan Harvey | last post by:
Hi all, I have written a web user control that contains a repeater control. the ItemTemplate for this control is basically 6 Hyperlinks in a row, that are dynamically allocated one of 7 gif...
5
by: Martin Dew | last post by:
Having some problems getting a hyperlink object to work in my repeater control, It displays the text I have asked it to for the hyperlink, but it does not act as a link. My repeater code is below...
10
by: david | last post by:
Hi, all: I need a help from you about DataGrid control. I created a DataGrid, dg, in design view of .NET visual Stadio and use the builder to add a Hyperlink column to dg. I want to try to assign...
2
by: Midsomer | last post by:
Hi. I have an Access database with a form containing 4 datasheets and I allow the user to change column widths. On closing the form, a routine is fired that saves each column width to an INI file....
20
by: tshad | last post by:
I had posted this problem earlier and just noticed that the Hyperlink is the problem. Apparently, it doesn't figure out the path correctly. It uses the path of the file it is in, even if it is...
6
Markus
by: Markus | last post by:
Ello. I'm trying to set the widths for my first three rows of cells and then have a bottom row with different cell widths. However, the first three rows take on the same widths as the bottom row. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.