Forum Moderators: not2easy

Message Too Old, No Replies

Broken Links

Applied CSS breaking links

         

venomizer

2:15 pm on Mar 20, 2009 (gmt 0)

10+ Year Member



Hi, i recently got asked by a friend to help him set up a website and although i've never done any form of web development, i decided to give it a shot. My issue at the moment is that when i apply a CSS to my main page, for some reason 2 of the 4 links on it become broken. I turned off the CSS and the links work and direct you to where they are suppose to. After testing the site on FireFox i learned that this issue is only on IE 7.

Here is the CSS. I apologize for any nightmares i give people with my terrible coding. I am a newbie in every sense of the word and everything i've learned has been a trial and error education.

body {
background-image: url(background.jpg);
background-repeat: no-repeat;
background-color: black;
background-position: center;
margin-top: 20px;
z-index: -1;
}

h1 {
font: 500% "GothicE";
text-align: center;
color: red;
}

#wws {
font: 200% "GothicE";
text-align: center;
margin-top: 400px;
margin-left: -600px;
padding: 0px;
}
a {
color: red;
text-decoration: none;
}

a:visited {
color: red;
}

a:hover {
color: #fff;
background-color:#707070;
text-decoration: none;
}

#members {
font: 200% "GothicE";
text-align: center;
margin-top: 150px;
margin-left: -400px;
padding: 0px;

}

#forum {
font: 200% "GothicE";
text-align: center;
margin-top: -67px;
margin-right: -300px;
padding: 0px;

}

#application {
font: 200% "GothicE";
text-align: center;
margin-top: -67px;
margin-right: -600px;
padding: 0px;

}

As for my doctype:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

I dont know if it makes a difference but i am using Ruby on Rails to develop the html code. For the links part, it comes out:

<h2 id="wws"><a href="http://www.example.com">WWStats</a></h2>
<h2 id="application"><a href="http://www.example.com">Application</a></h2>
<h2 id="members"><a href="internal_page">Members</a></h2>
<h2 id="forum"><a href="http://www.example.com">Forums</a></h2>

I'm thinking its just my complete inexperience with CSS and web development thats causing the issue so i figured i should ask the veterans.

penders

7:17 pm on Mar 22, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What do you mean by "broken"? Are they still visible, but just not clickable? Does your a:hover pseudo class still work?

With your large negative margins (to move things around presumably) it looks like you might be moving your H2s on top of each other - the covered anchor will then not be clickable? Add a temporary border to your H2s (or any other elements) to check for any overlaps:

h2 {border:1px solid #f00}

venomizer

6:12 pm on Mar 24, 2009 (gmt 0)

10+ Year Member



Sorry about that, yes i mean they are not clickable. As for the a:hover, it works on the 2 links that are clickable but not on the 2 that are unclickable.

I thought it could be the margins but wasn't sure. When i get home i will try the borders. If it is the margin issue, can you suggest an easier or cleaner way of positioning links? Again I'm pretty new at this stuff so even the simplest solutions are hidden to me.

Thanks for the reply

penders

8:39 pm on Mar 24, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



...can you suggest an easier or cleaner way of positioning links?

It really depends on what you are trying to do with them. But it is not normally correct to mark them up as level 2 headings. Often a list of links are just that... an unordered list...

<ul> 
<li id="wws"><a href="http://www.example.com">WWStats</a></li>
<li id="application"><a href="http://www.example.com">Application</a></li>
<li id="members"><a href="internal_page">Members</a></li>
<li id="forum"><a href="http://www.example.com">Forums</a></li>
</ul>

The LI's can be styled any way you like - much like you are trying to style your H2s.

Allowing the links to flow with the rest of the page content would perhaps be best for a flexible layout. However, you could opt to position:relative (your LIs) and set left, top, width and height? Or even position:absolute? If you set position then you can control overlapping by setting the elements z-index.

venomizer

9:19 pm on Mar 27, 2009 (gmt 0)

10+ Year Member



Thanks for all the help penders. The list idea was sort of the opposite direction i wanted to go with the links. My positioning was to place the links in a semicircle fashion around my background image.

Your idea of changing from margin management to position:absolute was what i was looking for. I applied a div for each h2 and presto, everything worked perfectly.

Thanks again penders for helping me out.

swa66

9:56 pm on Mar 27, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Don't discount the <ul> for a menu, it's far cleaner than a number of divs each holding a h2

Seriously: you can position the <li> where you want and the added advantage is that your code when rendered unstyled makes sense just as well as that making it a more traditional menu should you want that down the road can be done without changing the html all over the place.