Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I apply CSS style changes just for one page?

I have two css files:

  1. A main file (main.css)

  2. A specific page file (page5.css). My page.css contains main.css (@import url(main.css));)

My main.css has this as one part of it that sets the height of the page

#content {
    background:url(../images/image.png) no-repeat;
    width:154px;
    height:356px;
    clear:both;
}

This works fine for all the other pages, but at page 5, I need a little bit more height.

How would I go about doing it?

like image 300
Asim Zaidi Avatar asked Apr 12 '11 17:04

Asim Zaidi


2 Answers

You don't even need a separate CSS file necessarily. You can add classes to your body for various purposes, identifying page or page type being one of them. So if you had:

<body class="page5">

Then in your CSS you could apply:

.page5 #content {
  height: XXXpx;
}

And it would only apply to that page as long as it occurs after your main #content definition.

like image 143
mVChr Avatar answered Oct 02 '22 02:10

mVChr


Just re-define it somewhere after your @import directive:

#content { height: 456px }

for identical CSS selectors, the latter rule overwrites the former.

like image 44
Pekka Avatar answered Oct 02 '22 01:10

Pekka