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>

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

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.