Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resize fontawesome icons on change in screen size

Trying to change the size of the icons on a bootstrap grid with following code and the media query but can't seem to make it work.

@media only screen 
  and (min-device-width: 320px) 
  and (max-device-width: 480px)
  and (-webkit-min-device-pixel-ratio: 2) {
    .fa-5x {
      font-size: 1em;
    }
    h1 {
      color: red;
      font-size: 1em;
    }
  }

/* Portrait */
@media only screen 
  and (min-device-width: 320px) 
  and (max-device-width: 480px)
  and (-webkit-min-device-pixel-ratio: 2)
  and (orientation: portrait) {
    .fa-5x {
      font-size: 1em;
    }
    h1 {
      color: red;
      font-size: 1em;
    }
  }
<div class="row">
  <a href="washrooms.php">
    <div class="col-lg-4 col-xs-4">
      <center>
        <h3>
          <i class="fa fa-eye-slash fa-5x"></i> <br>Washrooms
        </h3>
      </center>
    </div>
  </a>
  <a href="intermidiate.php"> 
    <div class="col-lg-4 col-xs-4">
      <center>
        <h3>
          <i class="fa fa-shopping-cart fa-5x"></i> <br>Shops
        </h3>
      </center>
    </div>
  </a>
  <a href="intermidiateservice.php">
    <div class="col-lg-4 col-xs-4">  
      <center>
        <h3>
          <i class="fa fa-wrench fa-5x"></i> <br>Services
        </h3>
      </center>
    </div>
  </a>
</div>



</div>

The code intends to scale down icon size to fit small screens, but doesn't work. Can someone help point out what is wrong or help to achieve the purpose.

like image 832
Yashesh Avatar asked Jan 28 '26 02:01

Yashesh


1 Answers

For responsive font size you can use viewport width (vw).

For further reading

PS: this may not support all mobile browsers.

  • Help :)
like image 131
Help Avatar answered Jan 29 '26 17:01

Help



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!