Forum Moderators: not2easy

Message Too Old, No Replies

CSS Rollover Horizontal Centered Button Bar

A newbie needs some help!

         

Foxhole

4:53 pm on Apr 4, 2010 (gmt 0)

10+ Year Member



Hi all,

As I am fairly new to (X)HTML and CSS, I have started creating a website, I have successfully added a background image to the whole page which is centered, I have also created a header image(also centered) which I have fixed the width to 900px.

What I have been trying to do for a long time now is use 5 seperate rollover images for the buttons one image for hover, and another one for normal, positioned all horizontally inline, and centred on the page (I will size these images to match the fixed width).

I have used seperated images for the 2 states, I believe it is better to use a stacked image and move on the background so I will also need to incorporate this, the button size will be 180 x 35.

Would someone please show me how this is done?, Can I also just use the graphic I create for the button and not display the text?

The whole website I would like to be this fixed width, centred with a white backround about 5px larger all around the content on top of my background image.

Here is where I am so far, I have tried and deleted about 10 attempts so only one button graphic is listed at the moment.

    HTML:


<link rel="stylesheet" type="text/css" href="kwdstyles.css" />
</head>

<body>

<div class="whiteback">

<img class="kwdheader" src="kwd_graphics/kwdbanner.png" alt="headerimage"/>

<ul id="linkbuttons">

<li id="home"><a href="kwdhome.html" title="Home"><span>Home</span></a></li>
<li id="aboutus"><a href="kwdaboutus.html" title="About Us"><span>About Us</span></a></li>
<li id="services"><a href="kwdservices.html" title="Services"><span>Services</span></a></li>
<li id="portfolio"><a href="kwdportfolio.html" title="Portfolio"><span>Portfolio</span></a></li>
<li id="contactus"><a href="kwdcontactus.html" title="Contact Us"><span>Contact Us</span></a></li>

</ul>

</div>

</body>

</html>


    CSS


body {
background:#FFFFFF url('kwdbackgroundimg.jpg') scroll no-repeat center top;
margin-left: auto;
margin-right: auto;
}

img.kwdheader {
display: block;
margin-left: auto;
margin-right: auto;
}

div.whiteback {
background-color: #FFFFFF;
padding: 5px;
margin-left: auto;
margin-right: auto;
}

span {
display: inherit;
}
#linkbuttons {
font-family: Arial, sans-serif;
text-align: center;
text-decoration: none;
}

#linkbuttons li {
display: inline;
}

#linkbuttons li#aboutus a{
background-color: #FFFFFF;
width: 150px;
height: 40px;
}

#linkbuttons li#aboutus a{
background: url('kwd_buttons/kwdaboutusoff.png') no-repeat;
width: 150px;
height: 40px;
}

Sorry about the big help ask for my first post but I have been banging my head against a wall!

Thanks all, much appreciated,

Foxhole

Foxhole

3:51 pm on Apr 11, 2010 (gmt 0)

10+ Year Member



Hi all,
Right then, I have still been trying this for what seems like forever and a day now, The page layout that i'm trying to achieve is as follows:

The whole window is a centered fading image which works fine.

The web page will basically consist of a header image set to 900px wide (as will the entire page), centered, and 5 css horizontal rollover button links below also centred (to match the width). Below this will be the rest of the contents of the page, I would like the entire contents of the page including the header fitted with a white background that 'hangs over' the contents by 5px.

I have now got my css rollover link buttons changing state correctly as I rollover.

The problems I now have is:

There is a gap of around 10px between the header image and the horizontal menu bar.

The menu bar is not centered, it is about 40px from the left.

Only the text on the button is clickable and not the whole button itself.

Here is my code thus far:

    HTML:


<link rel="stylesheet" type="text/css" href="kwdstyles.css" />
</head>

<body>

<div id="whiteback">

<img id="kwdheader" src="kwd_graphics/kwdbanner.png" alt="headerimage"/>

<ul id="linkbuttons">

<li id="home"><a href="kwdhome.html" title="Home"><span>Home</span></a></li>
<li id="aboutus"><a href="kwdaboutus.html" title="About Us"><span>About Us</span></a></li>
<li id="services"><a href="kwdservices.html" title="Services"><span>Services</span></a></li>
<li id="portfolio"><a href="kwdportfolio.html" title="Portfolio"><span>Portfolio</span></a></li>
<li id="contactus"><a href="kwdcontactus.html" title="Contact Us"><span>Contact Us</span></a></li>

</ul>

</div>

</body>

</html>

    CSS


body {
background:#FFFFFF url('kwdbackgroundimg.jpg') scroll no-repeat center top;
margin-left: auto;
margin-right: auto;
}

#kwdheader {
display: block;
padding-top: 0;
margin-left: auto;
margin-right: auto;
}

#whiteback {
background-color: #FFFFFF;
padding: 0;
margin-left: auto;
margin-right: auto;
}

#linkbuttons ul {
display: block;
text-align: center;
}

#linkbuttons li {
background: url("kwd_buttons/kwdbutton.png") no-repeat 0 0;
float: left;
display: inline;
width: 150px;
height: 35px;
font-family: Arial, sans-serif;
text-align: center;
}

#linkbuttons li:hover {
background-position: 0 -35px;
}



Any help would be greatly appreciated as I am getting nowhere fast!

Thanks all.