Not as far as I'm aware unfortunately. I'm not sure you need anything "radically different"; you will need to change your markup very slightly, though it is entirely possible to do exactly what you're asking. It's difficult to offer a solution without knowing a little more about the context.
For instance, if you just wanted the content of the div
to be center aligned then I'd suggest text-align:center;
. If you want to have a background on the centered element then just nest another div
/span
etc inside. If you're really stuck then please explain a little more of what the purpose is, and I'll try to help you come up with a solution. Here's a solution based off that:
HTML
<div id="container" class="cf">
<div id="sidebar"></div>
<div id="message">
<span>hello world</span>
</div>
</div>
...Content after
CSS
.cf:before,
.cf:after {
content: " ";
display: table;
}
.cf:after {
clear: both;
}
#sidebar {
width:200px;
height:400px;
background-color:red;
float:left;
}
#message {
display:block;
text-align:center;
}
#message > span {
padding:10px;
background:blue;
display:inline-block;
color:white;
}
Here, I float only the #sidebar
. The #message
div then takes up a display:block
and using text-align:center
, center-aligns the nested span within. You'll notice that I'm also using the micro clearfix hack, .cf
as you'll need to clear your floats afterwards.
Edit: I just changed the span to be inline-block
, and added a padding to demonstrate that it's working.