Make mobile like desktop

Asked

Viewed 67 times

0

I own a section on my website that on the desktop presents the expected behavior, a row divided into 3, using col-md-4, on the desktop the behavior is normal, on mobile tried to use col-xs-4 to be divided correctly, but the result was not as expected.

Como é para ficar no desktop e mobile

It is to have that same behavior in mobile, but it is breaking one below the other.

Como esta

HTML

  <section class="third-section">
<div class="container">
  <div class="row">
    <div class="col-md-4 col-xs-4 d-flex justify-content-start">
      <h4>Entre em contato com a gente:</h4>
    </div>

    <div class="col-md-4 col-xs-4 phone">
      <div class="d-flex align-items-center resd">
        <p> 51 9999999</p>
      </div>
      <div class="d-flex align-items-center"><img src="img/iconwpp.png" alt="icone whatsapp">
        <p>51 99999999</p>
      </div>
      <div class="d-flex align-items-center"><img src="img/iconwpp.png" alt="icone whatsapp">
        <p>51 99999999</p>
      </div>
    </div>

    <div class="col-md-4 col-xs-4 address">
      <p>Rua XXXXX</p>
      <p>xxxxxxxxxxxxx/RS</p>
      <p>CEP 00000-000</p>
    </div>
  </div>
</div>

CSS

.third-section {
margin-top: 5%;
margin-bottom: 5%;
padding-left: 35%;
padding-right: 30%;

.phone {
img {
  margin-right: 3px;
  margin-bottom: 20px;
  height: 20px;
}
.resd {
  margin-left: 23px;
 }
}

1 answer

0

The class with -xs is no longer used in Bootstrap 4. The correct would be just col-4 for breakpoints smaller than 576px as shown in the table in official documentation of Bootstrap 4.

In this case, if you want to leave 3 columns in any breakpoint, just use col-4, i.e., the col-md-4 is not necessary since the col-4 is the default and will be applied in any resolution, since the number of columns will not change according to breakpoint.

Example:

I added colors to the columns for visualization.

.third-section {
margin-top: 5%;
margin-bottom: 5%;
padding-left: 35%;
padding-right: 30%;
}

.third-section .phone img {
  margin-right: 3px;
  margin-bottom: 20px;
  height: 20px;
}
.third-section .resd {
  margin-left: 23px;
}
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<section class="third-section">
<div class="container">
  <div class="row">
    <div class="col-4 d-flex justify-content-start" style="background: red;">
      <h4>Entre em contato com a gente:</h4>
    </div>

    <div class="col-4 phone" style="background: blue;">
      <div class="d-flex align-items-center resd">
        <p> 51 9999999</p>
      </div>
      <div class="d-flex align-items-center"><img src="img/iconwpp.png" alt="icone whatsapp">
        <p>51 99999999</p>
      </div>
      <div class="d-flex align-items-center"><img src="img/iconwpp.png" alt="icone whatsapp">
        <p>51 99999999</p>
      </div>
    </div>

    <div class="col-4 address" style="background: green;">
      <p>Rua XXXXX</p>
      <p>xxxxxxxxxxxxx/RS</p>
      <p>CEP 00000-000</p>
    </div>
  </div>
</div>
</section>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.