July 31, 20179 yr Hi guys, I'm using clearfix in order to make a to column layout. I've 2 divs inside a parent div but despite I use .clearfix parent box collapses. Here's the codepen https://codepen.io/mikelamardes/pen/KvzaLP
August 1, 20179 yr Author You've spelt clearfix wrong on your div tag. Can you tell me please, why my home page is not centered, https://codepen.io/mikelamardes/pen/KvzaLP
August 1, 20179 yr Can you tell me please, why my home page is not centered, https://codepen.io/mikelamardes/pen/KvzaLP Do you mean the content? You can't have margin: 0 auto; on a 100% width item because it visually won't appear in the center. I would use classes instead so you're able to re-use various width containers to display content. Here's an example https://codepen.io/anon/pen/dzMxQg. There's no use in setting a width on something that doesn't require one, you will make it harder to re-use what you have already.
August 1, 20179 yr Author Do you mean the content? You can't have margin: 0 auto; on a 100% width item because it visually won't appear in the center. I would use classes instead so you're able to re-use various width containers to display content. Here's an example https://codepen.io/anon/pen/dzMxQg. There's no use in setting a width on something that doesn't require one, you will make it harder to re-use what you have already. So my parent box can not center the children inside if its size is 100% am I right?
August 1, 20179 yr So my parent box can not center the children inside if its size is 100% am I right? Sort of. Your parent div with a width of 100% is likely in the center, but you just can't see it because it spans full width. It won't center the child items automatically, the way this is usually done is to wrap them in a smaller container like in my example above. If you want the text to be centered inside of that, you can use text-align. I've updated my example here to show how that works https://codepen.io/anon/pen/JyKoxv.
Create an account or sign in to comment