Search code examples
csswordpresshtmlcentering

Div not Centering in WordPress


I'm trying to get a div to be centered on the page. however WordPress isn't cooperating and doing it like it does in my testing HTML document. Any ideas?

HTML

<div class="propreq grid_4"><h2>Request a Proposal</h2></div>

CSS

.propreq {
    margin: 0 auto;
    text-align: center;
    padding-top: 20px;
    padding-bottom: 10px;
    background-color: #0e7bd0;
}

Solution

  • Looks like it's because of a couple things. Try adding the styles below to your current definition (or changing them, if they're already there):

    .propreq {
        display: block;
        float: none;
    }
    

    Before, .propreq had display:inline, float:left applied to it, making the styles you were applying to it ineffective. I hope this gives you what you were looking for! If not, let me know and I'll be happy to help further. Good luck!