- This topic has 15 replies, 3 voices, and was last updated 7 years ago by Leo.
-
AuthorPosts
-
April 18, 2017 at 9:39 am #307368sdanbu
Is there a way to control the size of the inner container of a section?
I would like to shrink the inner container to a percentage of the page.Thanks
This is a follow up to the section question
https://generatepress.com/forums/topic/is-there-a-way-to-set-inner-box-background-color-for-a-section/#post-307344April 18, 2017 at 11:27 am #307406TomLead DeveloperLead DeveloperIf you give the section a class, you could do this:
.my-section-class > div { max-width: 70%; margin: 0 auto; }
April 18, 2017 at 8:29 pm #307538sdanbuFor some reason this didn’t work. I put “my-section-class” in the custom class field in the section that I was targeting but it still didn’t work.
Did I do something wrong? Thanks for your help.April 18, 2017 at 8:32 pm #307543LeoStaffCustomer SupportCan you provide a link to your site so we can have a look? Thanks!
April 25, 2017 at 9:28 am #310128sdanbuThe link for this issue is the same as the link for the other private email. Thanks!
Basically I want to adjust the size of section containers but this CSS code above didn’t work for that for some reason.April 25, 2017 at 9:33 am #310136TomLead DeveloperLead DeveloperCan you try re-copying and pasting the code above? It looks like something went wrong and some characters were converted the last time you pasted.
Let me know 🙂
April 25, 2017 at 9:53 am #310150sdanbuI tried it and it works — but I have a question
If I want the width to be smaller, do I change the 70% to xx% that is smaller?
Or do I change margin attribute to something besides 0 auto
.my-section-class > div {
max-width: 70%; <—-
margin: 0 auto; <—-
}April 25, 2017 at 9:55 am #310151LeoStaffCustomer SupportModify the percentage should work.
April 25, 2017 at 10:12 am #310159sdanbuWait actually it doesn’t work
Am I supposed to find the section and under settings > Custom Classes > put the title .my-section-class?
.my-section-class > div {
max-width: 70%;
margin: 0 auto;
}April 25, 2017 at 10:51 am #310181LeoStaffCustomer SupportAdd the class in without the dot:
my-section-class
April 25, 2017 at 11:19 am #310198sdanbuI think max width works on desktop but not on mobile because it becomes full screen which is fine.
Is there a minimum width or a fixed width setting as well?
Or maybe I need to use margin?
April 25, 2017 at 12:18 pm #310212LeoStaffCustomer SupportThere is
min-width
andwidth
for fix width. Wouldn’t recommend using though as I don’t think they would be responsive.You can target mobile with CSS like this though:
@media (max-width: 768px) { .my-section-class > div { max-width: 70%; margin: 0 auto; } }
April 25, 2017 at 12:44 pm #310220sdanbuHm… not sure it’s working. I found this code – This kinda works but I don’t know how to make one part of the section “.outer” and one part of the section “.inner”.
https://www.sitepoint.com/css-center-position-absolute-div/
.outer {
position: relative;
width: 40%;
height: 120px;
margin: 20px auto;
border: 2px solid #c00;
}.outer {
position: relative;
width: 40%;
height: 120px;
margin: 20px auto;
border: 2px solid #c00;
}.inner {
position: absolute;
width: 100px;
height: 100px;
top: 10px;
left: 50%;
margin-left: -50px;
background-color: #00c;
}April 25, 2017 at 2:07 pm #310253LeoStaffCustomer SupportSorry I’m little confused what you are trying to achieve here?
The code should work for mobile…Can you try clearing browser cache maybe?
April 26, 2017 at 5:59 am #310483sdanbuIt turns out that it worked when I called the section directly for example
#generate-section-4 .generate-sections-inside-container {
background-color:rgba(63,96,119,0.5);
max-width: 30%;
margin: 0 auto;
}Thanks!
-
AuthorPosts
- You must be logged in to reply to this topic.