Hello,
I am trying to adjust the padding of #main per page.
I really just need my homepage to be different from all of my other pages but have not been able to successfully accomplish this.
#main {
padding: 2px;
}
is what I need on my homepage due to the use of a slider but on all of my other pages I need something more like
.page-id-CC #main {
padding: 20px 50px;
}
but I can only get one or the other to work even if I try to identify my home page using the id.
I have 6 pages total including the homepage.
How can I accomplish this? Any help provided would be greatly appreciated.
By add a class to all of the pages except for my homepage, I was able to accomplish this.
This can be marked as resolved.
Hi TechEng,
Sorry for the delay but it should be noted that the home class is always attached to the homepage body so you could replace .page-id-CC with .home.
Here’s my typical canned response on targeting specific pages.
On every WordPress page, you’ll find a unique ID class that will allow you to directly target that page and only that page. It’s always attached to the body of the page. Getting the classes of the body via our Custom CSS plugin can be quite tricky. Instead, let’s simplify it. Open up the page you would like to target. Then, if you’re in Chrome, Firefox or any other WebKit-based browsers, press CTRL + U. If you’re using Internet Explorer right click anywhere and select the “View Source Option”.
You’ll now see the markup of this page. Press CTRL + F and type in <body
There's also a couple of other useful classes attached to it and here's a quick rundown of what is attached to my local home page.
home
This class is only ever present when the current page is the homepage.
page
This tells you that the current page is a page. This is only present on actual pages (read: WordPress defined pages) and will be replaced with something else on non-pages. (example being single-post)
page-id-49
This is that unique ID I was talking about before. If you target this class it will ONLY affect this page.
logged-in
Only present if the user is logged in.
admin-bar
Only present if the admin bar is visible (remember, this can be disabled by the user)
siteorigin-panels
This is present when the page was built using SiteOrigin Page Builder.
—
Hopefully, this helps you. I would also recommend giving this article a read, How CSS Selectors Work.