I create a website with a flat design. I have a headline and below it are two different colored blocks next to each other. I tried float left and right, but I was recommended to use display: inline-block instead.
I ran into a problem. I want to place the text right in the middle of both the left and right blocks and tried to use alignment elements: center, but realized that it only works if the div is set to flex.
So my question is: can I somehow save my built-in block and get the text in the center of my blocks (both horizontally and vertically)?
body { margin: 80px 0 0; } #pagewrapper { width: 100%; } #header { width: 100%; height: 80px; background-color: #008B8B; position: fixed; top: 0; } .content-left, .content-right { width: 50%; height: 500px; color: #FFFFFF; display: -moz-inline-stack; display: inline-block; zoom: 1; *display: inline; } .content-left { background-color: #66CC99; } .content-right { background-color: #20B2AA; } #header-bot { height: 800px; background-color: #F8F8FF; } #footer { height: 50px; background-color: #AFEEEE; } .title { font-size: 18px; }
<body> <div id="pagewrapper"> <div id="header"> </div> <div class="content-left"> <span class="title">This is left Content</span> </div> <div class="content-right"> <span class="title">This is Right Content</span> </div> <div id="header-bot"> </div> <div id="footer"> </div> </div> </body>
source share