Jump to content

center a DIV and its content, but not center content of its parent DIV


jasonc

Recommended Posts

basically i would like the messageDiv to be in the center of the results div but leaving the results div alone as it is floated to the left.

 

.results { border-top: 1px solid #F0F0F0; border-left: 1px solid #E5E5E5; border-right: 1px solid #E5E5E5; float: left; width: 695px; margin-left: 5px; padding: 3px; font-size: 9pt; }
.messageDiv { width: 500px; border-radius:15px; border: 1px solid #A5260F; background: #E28B65; margin: 5px 0 5px 0; text-align: center; }

 

<div class="results">
<div class="messageDiv"><?=$message;?></div>
</div>

Link to comment
Share on other sites

change your code to this

 

.messageDiv { 
  margin:5px auto;  /* instead of 0 i set it to auto */
  width: 500px; 
  border-radius:15px; 
  border: 1px solid #A5260F; 
  background: #E28B65; 
  text-align: center; 
}

 

if this solved it for you (which i know it does ) please mark it solved, same is for your other questions, or at least be as polite as to respond. We are not responding to trees here.

 

http://www.phpfreaks.com/forums/index.php?topic=336354.0

http://www.phpfreaks.com/forums/index.php?topic=336773.0

http://www.phpfreaks.com/forums/index.php?topic=336656.0

http://www.phpfreaks.com/forums/index.php?topic=336429.0

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.