How can I edit the CSS of a specific page?
This is a Hitskin.com skin preview
Install the skin • Return to the skin page
This is a Hitskin.com skin preview
Install the skin • Return to the skin page
$(function() {
if (/\/u\d+/.test(window.location.href)) {
document.body.className += ' user-profile';
}
});
.user-profile {
background:#900;
}
|
Ange Tuteur wrote:Using the templates would be an ideal way, since it would require little JavaScript. However, if that's not possible, you can use JavaScript to add a class to the body for a specific page.
For example :
Add this script in all the pages :
- Code:
$(function() {
if (/\/u\d+/.test(window.location.href)) {
document.body.className += ' user-profile';
}
});
Then you can use CSS to specifically modify the user profile elements :
- Code:
.user-profile {
background:#900;
}
The class is added to thetag so you can select any element inside it with the specific class.
- Code:
<body>
$(function() {
if (/\/f\d+/.test(window.location.href)) {
document.body.className += ' forum-page';
}
});
$(function() {
if (/\/f2(?:-|p\d+-)websites/.test(window.location.href)) {
document.body.className += ' forum-page-websites';
}
});
Ange Tuteur wrote:If it's for all forum pages you can do this :
- Code:
$(function() {
if (/\/f\d+/.test(window.location.href)) {
document.body.className += ' forum-page';
}
});
If it's for that page only, you can do this instead :
The number "2" is the forum ID.
- Code:
$(function() {
if (/\/f2(?:-|p\d+-)websites/.test(window.location.href)) {
document.body.className += ' forum-page-websites';
}
});