Center floated div or any elements

<div class"fullwidth"> <div class="container align-center"> <div class="row"> <div class="block">1</div> <div class="block">2</div> <div class="block">3</div> </div> </div> </div> <style> *, *:before, *:after { box-sizing: border-box; margin: 0; padding: 0; } .fullwidth { margin:50px 0; width:100%; } .container { max-width:960px; } .align-center { text-align:center; } .row { display:inline-block; } .block { float:left; width:200px; height:200px; text-align:center; padding:20px; margin:0 10px 10px; font-size:24px; background-color:#9ABBC6; color:#fff; } </style>
Center any floated element or div in a container.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.