Forum Moderators: not2easy
I am building my first web site using an entirely CSS based layout.
Index [and several other] page[s] take the format: Banner,Left/centre/right columns, footer.
However, some pages do not need a three column layout and I want to remove the extreme right column from those pages only. With the right column removed from the HTML of those pages, I am now left with a centre column which does not extend to the right side of the page because the position of the right hand edge of the centre column is determined by padding.
Brief code as follows:
#center {
background-color : transparent;
padding : 140px 220px 35px 160px;
margin: 0;
}
#centercontent{
font-size: 80%;
padding: 5px;
border : 1px solid black;
}
My question is this: Is there a way to control the right padding using a "conditional" statement, something like - IF PRESENT "right" THEN padding-right:160 ELSE padding-right:0
Or do I have to use a different style sheet for those pages?
Many thanks.
Spook
So on the pages that you don't want the right column to appear you could specify an id (or class) for the body tag, like this..
<body id="indexpage">
then in your CSS rules you can specify additional rules for #center when it appears within a #indexpage body
#center {
background-color : transparent;
padding : 140px 220px 35px 160px;
margin: 0;
}
#indexpage #center {
padding-right: 0px;
}
I've had to do it once before, but usually find there are really good ways to avoid having to do this.
#indexpage #center {
padding-right: 0px;
}
And no element on the page has the id 'indexpage', you can assign that ID with javascript and the page will apply the rule and redraw!
To give that ID to the body element:
document.body.id = 'indexpage';
Using javascript in this way - to trigger a bunch of "hidden" rules in the style sheet - is cleaner and simpler in many instances than the javascript-only approach.
It can work with classes, too, of course.
thanks again!
<style>
$color1 {#eadfbe}
$color2 {#ffffff}
$color3 {#32f49e}BODY {background-color: $color1; color: $color3;}
TD {border: 1px solid $color2}
.nav_bar {background-color: $color2;}
</style>
Get the idea? That way it's even easier to change your entire site's style instantly. If you want to change the color scheme, you just change your standard color variables.
I don't know if other developers are like me, but I usually come up with a style guide for my sites and I usually don't use more than 10 or so colors throughout the entire site for consistency purposes. Changing the entire site in a heartbeat would be much easier with this, especially if you could define any kind of variable this way.