Jump to content

Adding margins to container when centered


vchris
 Share

Recommended Posts

I have this code for my container

#container { width: 600px; margin: 0 auto; }

So basically I have a centered container on my page which I want to add some margins into it so the text is not right against the borders.I tried with padding but this creates spaces outside the container and I no longer have my width of 600px. If I try margins then the container is no longer centered and is placed depending on the margins I specified. I don't understand why it's not working, I've done it before.Thanks for the help.

Link to comment
Share on other sites

Have your tried adding a span's for your text? You can have your container with your styling, but you can also have your text with it's own styling... something like this:html:

<div id="container"><span>Text Here</span></div>

css:

#container { width: 600px; margin: 0 auto; }#container span {padding: 3px;}

Maybe?

Link to comment
Share on other sites

So it's not just for one container I'm assuming then. Well, that's really all I can come up with. Perhaps someone else can give you a better suggestion then. :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...