0

Image is attached what i wanna get

Hello everyone I tried to get help form google and it did not work for me i have tried display as table-cells, table, flex, grid etc. So i am looking for some help if you can thank you everyone.

<html>
    <style>
.contact-us{
    background-color:  grey;
    width: 100%;
    min-height: 230px;
    padding: 50px 300px 50px 300px;
    display: grid;
    text-align: center;
    color: #fff;
    vertical-align: middle;
}
.contact-us .btn{
  width: 100px;
  height: 30px;
  text-align: center;
  font-size: 13px;
  display: grid;
}
    </style>
    <body>
        <div class="contact-us">
            <h2>CONTACT US TODAY</h2>
              <h5>Have any questions or comments? Need a WINZ quote? Call us at (022) 1736590.</h5>
              <button class="btn">CONTACT US</button>
        </div>
    </body>
</html>

2 Answers2

1

I like the flex-box approach.

We'll make the body element full height and then center your contact-us element in the center of the body using flex-box.

<html>
  <style>=
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    body {
      display: flex;
      justify-content: center;
      align-items: center;
      background-color:  grey;
      min-height: 100vh;
    }
    
    .contact-us{
      text-align: center;
      color: #fff;
    }

    .contact-us .btn{
      width: 100px;
      height: 30px;
      text-align: center;
      font-size: 13px;
    }
  </style>
  <body>
    <div class="contact-us">
      <h2>CONTACT US TODAY</h2>
      <h5>Have any questions or comments? Need a WINZ quote? Call us at (022) 1736590.</h5>
      <button class="btn">CONTACT US</button>
    </div>
  </body>
</html>
cam
  • 3,179
  • 1
  • 12
  • 15
1

.contact-us {
text-align: center;
}

h2{
text-align:left;
}

h5{
text-align: left;
}
<html>
    <style>
.contact-us{
    background-color:  grey;
    width: 100%;
    min-height: 230px;
    color: #fff;
    vertical-align: middle;
}
.contact-us .btn{
  width: 100px;
  height: 30px;
  font-size: 13px;
}
    </style>
    <body>
        <div class="contact-us">
            <h2>CONTACT US TODAY</h2>
              <h5>Have any questions or comments? Need a WINZ quote? Call us at (022) 1736590.</h5>
              <button class="btn">CONTACT US</button>
        </div>
    </body>
</html>

Make it much shorter. no need to use flex.! flex is partial supported in IE and its not good to use.

div {
text-align: center;
}
<div>
  <button>Im Centered!</button>
</div>
SoliMoli
  • 781
  • 2
  • 6
  • 25