CSS 2 Box Properties - Post ID 205470

User 2924428 Photo


Registered User
1,718 posts

hey guys I was wondering if anyone knew the code I could use to align different boxes within my site? I'm actually starting over brand new site at www.kingfizz.com, take a look at the code there, thanks guys! Oh yeah I want to center them..
User 187934 Photo


Senior Advisor
20,266 posts

This is one way. I see you already have a .center class in your css.
<div class="ex center">
now in your css
div.ex.center {
border: 5px solid gray;
margin-left:auto;
margin-right:auto;
padding: 10px;
width: 220px;
}
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 122279 Photo


Senior Advisor
14,624 posts

Ooops, Eric! That 'margin_right' is supposed to be 'margin-right'.

Instead of specifying the left and right margin, if they are both auto, it can be written:

margin: auto;
Ha en riktig god dag!
Inger, Norway

My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com


User 187934 Photo


Senior Advisor
20,266 posts

Thanks Inger,
I knew you would come to the rescue.:) I fixed it.;)
I always write mine separate out of habit because it always seems that I'm coming back to tweak the top or bottom margin.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 122279 Photo


Senior Advisor
14,624 posts

You can also write:

margin: 0 auto 5px;

then you have the top and bottom in there. Well, I guess you knew that ;)
Ha en riktig god dag!
Inger, Norway

My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com



Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.