Forum Moderators: not2easy
I am new here but feel I will have lots of questions going forward, as I am getting into webdesign much more and enjoy it.....
I am creating a new page- slowly but surely.... The problem I have is similar to one which was answered a couple months ago from a thread i read, but I am so new, I am afraid i don't understand because the code was from someone else's situation. I feel I need to ask it as it pertains to my situation, so here goes...
So I want to put different headers on different pages, but the CSS is overriding.
Here is the CSS part that is overriding:
/** layout **/
#wrapper {
width: 678px;
min-height: 750px;
_height: 750px;
background: url(images/header.jpg) no-repeat;
position: relative;
background-image: url(images/header.jpg);
}
And the HTML:
<div id="wrapper">
Actually, looking through the html file, i don't see the header file at all, although in dreamweaver i can browse to the image file i want....
So in a nutshell, on the first page i want images/header.jpg and on the second i want images/header2.jpg etc.. etc... I may add more header images when i make more pages if i can learn what to do with just 2 to start...
I am extremly new at CSS so i need cut and paste instruction basically. I appreciate any and all help and I hope i have explained correctly and inserted the appropriate info needed above.
Regards,
Maceman
Thanks for stripping your code, and posting your doctype ;)
Looking at your code, there are a couple suggestions I'd also like to make in addition to trying to answer the quesation.
background: url(images/header.jpg) no-repeat; PLUS background-image: url(images/header.jpg); (you don't need both), AND whether you really need position: relative; when you check them out. _height: 750px; is a "hack" that sends a height internet explorer versions 6 and below because they don't understand min-height. However, later versions do, so the best way is to send the difference using a conditional comment. (Check out the post in the forum library.) Actually, looking through the html file, i don't see the header file at all, although in dreamweaver i can browse to the image file i want....
So in a nutshell, on the first page i want images/header.jpg and on the second i want images/header2.jpg etc.. etc... I may add more header images when i make more pages if i can learn what to do with just 2 to start...
There are many ways to do this, but this is one:
In your css
#wrapper {
width: 678px;
min-height: 750px;
_height: 750px;
}.headerone {
background: #ff0 url(images/header.jpg) top left no-repeat;
}.headertwo {
background: #ff0 url(images/header2.jpg) top left no-repeat;
}In your html
<div id="wrapper" class="headerone"> ...
and for the other image:
<div id="wrapper" class="headertwo">
Another option is multiple classes:
In your css
.wrapper { /*note change to class by using a dot */
width: 678px;
min-height: 750px;
_height: 750px;
}.headerone {
background: #ff0 url(images/header.jpg) top left no-repeat;
}.headertwo {
background: #ff0 url(images/header2.jpg) top left no-repeat;
}In your html
<div class="wrapper headerone"> ...
and for the other image:
<div class="wrapper headertwo">
In your external stylesheet
#wrapper {
width: 678px;
min-height: 750px;
_height: 750px;
}In your html
<style type = "text/css">
#wrapper {
background: #ff0 url(images/header.jpg) top left no-repeat;
}
</style>
<body>
<div id="wrapper"> ...And just change the image to
etc as suitsheader2
[edited by: alt131 at 10:15 pm (utc) on Sep. 29, 2008]
then this should work however for your second page your should change the id of the header to something like header2 like so:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
<title>Page Title</title>
<style type="text/css" media="screen">
#header {background: url(images/header.jpg) no-repeat top;}
#header2 {background: url(images/header2.jpg) no-repeat top;}
</style>
</head>
<body>
<div id="wrapper">
<div id="header2">
<!-- your header content should be here -->
</div>
<div id="content">
<!-- your main content should be here -->
</div>
</div>
</body>
</html>
notice there's an additional css rule within the head and header id has been changed to header2. The additional css rule will now overwrite the first rule to apply a new background image. Personally this wouldn't be my approach but it will get the result you want.
Now, just as a point of clarification, when you say
"In your html
<div id="wrapper" class="headerone"> ...
and for the other image:
<div id="wrapper" class="headertwo">"
do you mean in each and every html i would put this? So in my case I have 2 files(so far), so i would put this into both html files?
Thanx in advance!
Ok, great... I understood now what you meant. You meant to put the one div id in the first html page, and the other in the second... Wonderful...
Ok, that worked awesome, except for some weird anomoly of yellow that now appears. Can you please have a look for me at <removed> and the other page is the contact.html. Both have yellow that wasn't there before- may be an easy fix, but I need help please. Thanx!
[edited by: jatar_k at 12:54 am (utc) on Sep. 30, 2008]
[edit reason] no urls thanks [/edit]
Now, just as a point of clarification, when you say ...
So in my case I have 2 files(so far), so i would put this into both html files?
think - I want header.jpg so:
.headerone {background: #ff0 url(images/header.jpg) top left no-repeat; }
so use:
<div id="wrapper" class="headerone">
think - I want header2.jpg so:
.headertwo{ background: #ff0 url(images/header2.jpg) top left no-repeat; }
so use:
<div id="wrapper" class="headertwo">
think - I want more image options so write new rules - eg header3.jpg
.headerthree { background: #ff0 url(images/header3.jpg) top left no-repeat; }
and use:
<div id="wrapper" class="headerthree">
.headerone to .header to exactly match header.jpg if it helps
Think about what you are trying to achieve, plus the scale of the information you will utlimately be working with to figure the question/forum.
can I use php on one of my pages, and not use it on the others,
All the other thoughts you have are quite possible too - it just depends on the final outcome, and what technology (eg coding languages) you want to use.)
However to keep this real simple - for something that will not ever be huge - might be show/hide. Do a search for "stu nicholls" and check out "dmonstrations", "show me more" to see if something like that could be modified for your pupose.
Have a think about possibilities and post a new thread in the appropriate forum.