Saoud ElTelawy
Saoud ElTelawy

Reputation: 196

(Bootstrap 4) : Align Button with the text to be same line

How to align all divs to be center on the same line. What I mean I want the button to be centered with text like such image, for example, the social icons are centered like text not down like mine in dark

enter image description here

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<footer id="main-footer" class="bg-dark">
    <div class="container d-flex flex-sm-column  justify-content-between py-3">
      <div class="row  py-4 text-center align-content-between flex-wrap">
        <div class="col-lg-4 mb-3">
          <p class="text-secondary">Copyright &copy; Saud</p>
        </div>
        <div class="col-lg-4 mb-3 ">
          <!-- Button trigger modal -->
          <button type="button" class="btn btn-primary " data-toggle="modal" data-target="#exampleModal">
            Contact Us
          </button>
        </div>
        <div class="col-lg-4 mb-3">
          <ul class="list-inline quicklinks">
            <li class="list-inline-item">
              <a href="#">Privacy Policy</a>
            </li>
            <li class="list-inline-item">
              <a href="#">Terms of Use</a>
            </li>
          </ul>
        </div>
      </div>
    </div>
  </footer>

Upvotes: 1

Views: 5050

Answers (2)

Carol Skelly
Carol Skelly

Reputation: 362290

To center align them, make the columns d-flex and use align-items-center...

    <div class="row text-center py-4 align-content-between flex-wrap">
        <div class="col-lg-4 d-flex justify-content-center align-items-center">
            <p class="text-secondary mb-0">Copyright &copy; Saud</p>
        </div>
        <div class="col-lg-4">
            <!-- Button trigger modal -->
            <button type="button" class="btn btn-primary " data-toggle="modal" data-target="#exampleModal"> Contact Us </button>
        </div>
        <div class="col-lg-4 d-flex justify-content-center align-items-center">
            <ul class="list-inline quicklinks mb-0">
                <li class="list-inline-item">
                    <a href="#">Privacy Policy</a>
                </li>
                <li class="list-inline-item">
                    <a href="#">Terms of Use</a>
                </li>
            </ul>
        </div>
    </div>

https://codeply.com/p/BBJM8P9UPR

Upvotes: 6

Rafael Tavares
Rafael Tavares

Reputation: 6460

You want to align all the elements by its' texts, right? If so, in the div.row add align-items-baseline class. See Bootstrap and MDN documentation for details.

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<footer id="main-footer" class="bg-dark">
  <div class="container d-flex flex-sm-column  justify-content-between py-3">
    <div class="row  py-4 text-center align-content-between flex-wrap align-items-baseline">
      <div class="col-lg-4 mb-3">
        <p class="text-secondary">Copyright &copy; Saud</p>
      </div>
      <div class="col-lg-4 mb-3 ">
        <!-- Button trigger modal -->
        <button type="button" class="btn btn-primary " data-toggle="modal" data-target="#exampleModal">
            Contact Us
          </button>
      </div>
      <div class="col-lg-4 mb-3">
        <ul class="list-inline quicklinks">
          <li class="list-inline-item">
            <a href="#">Privacy Policy</a>
          </li>
          <li class="list-inline-item">
            <a href="#">Terms of Use</a>
          </li>
        </ul>
      </div>
    </div>
  </div>
</footer>

enter image description here

Upvotes: 2

Related Questions