- This topic has 7 replies, 3 voices, and was last updated 3 years, 6 months ago by
David.
-
AuthorPosts
-
September 11, 2022 at 11:32 am #2339842
Jusung
Hello.
I want to change a single page’s background color while not changing the background-colors on other pages.
I know the code for that, but I don’t know the specific ID for a page.
Is there a way to know the ID or do I need to set the ID? if so, how I can give an id to a page?I want to change only the front page’s background color to white.
September 11, 2022 at 12:21 pm #2339884Matthew
There are a couple easy ways to do this:
1. Use a body class to target your CSS: Each page/post in wordpress has a unique class added to the body tag which includes the ID of the page. You can target that CSS class to change the background color on only that page.
2. Use Inline CSS (recommended): Use the HTML block to add inline CSS to the page/post itself. Simply add your CSS between <style></style> tags. Like this:
<style> body { background-color: #fafafa; } </style>By pure luck, I’ve actually written a tutorial on this on my site: https://www.buildthatwebsite.com/change-background-color-specific-page
September 11, 2022 at 12:25 pm #2339891David
StaffCustomer SupportThanks for sharing that Matthew.
Jusung – let us know how you get on 🙂September 11, 2022 at 11:45 pm #2340152Jusung
Thank you Matthew and I read your article.
on our article, you explained how to find the ID well and I was able to resolve this now!
Thank you!
September 12, 2022 at 2:31 am #2340284Jusung
an issue has occured.
I was able to change the background color of a single page.
but on mobile, it has been changed. I don’t know why.Can you help me to change the background color to white on mobile device
(front page)This is what I added
body.page-id-766 {
background-color: white;
}September 12, 2022 at 3:18 am #2340327David
StaffCustomer SupportOk, so you have the Customizer > Color > Body, which is now white on that page.
But you also have the Customizer > Color > Content, which is the other color you see due to the padding on mobile.You can use this CSS to target both elements:
body.page-id-766 .inside-article, body.page-id-766 { background-color: white; }September 12, 2022 at 3:21 am #2340330Jusung
Thank you millions!!!!!
September 12, 2022 at 5:57 am #2340439David
StaffCustomer SupportYou’re welcome
-
AuthorPosts
- You must be logged in to reply to this topic.