Jump to content

CSS Center


sseeley

Recommended Posts

It's not the easiest thing to do. You probably have to trick the system into it like this:

 

<div id="container">
  <div id="item_to_be_offcenter">div contents</div>
</div>

 

Then you can set the CSS like this:

#container
{
  width: 300px; 
  margin: 0 auto;
}
#item_to_be_offcenter
{
  margin-left: -50px;
}

 

This code creates a container that is centered, holding the items that are to be off center by 50 px. A negative left margin is then used to move the contents to 50 px off the center.

 

 

Link to comment
https://forums.phpfreaks.com/topic/172479-css-center/#findComment-909504
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.