Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create responsive text in bootstrap 4? [closed]

can anyone pls help me in responsive text using Bootstrap 4. I searched everywhere but wierd to see no tutorial in this regard. Here are my codes in case if you want to guide me.

<div class="container">
  <div class="row">
    <div class="col-md-12">
      <div style="font-size: 3rem;">Hello World</div>
    </div>
  </div>
</div>
like image 453
Emraan Aly Avatar asked Feb 01 '18 21:02

Emraan Aly


People also ask

How do I make text size responsive in Bootstrap 4?

Responsive font sizes RFS can be enabled by changing the $enable-responsive-font-sizes Sass variable to true and recompiling Bootstrap. To support RFS , we use a Sass mixin to replace our normal font-size properties.

Is Bootstrap font size responsive?

There are no dedicated mixins for typography, but Bootstrap does use Responsive Font Sizing (RFS).

How do I center text in Bootstrap 4?

Text Alignment The text can justified by using the . text-justify class and for left, right, and center alignment of text, use the text-left, text-right and text-center classes respectively.


1 Answers

Well, this is described in the Responsive typography section of the Bootstrap 4 documentation. From the docs: Bootstrap doesn’t do this for you, but it’s fairly easy to add if you need it.

It is indeed not that hard. Basically you have to define the font sizes on the <html> tag for each media breakpoint.

Here is an example:

html { font-size: 1rem; }

@media (min-width: 576px) {
    html { font-size: 1.25rem; }
}
@media (min-width: 768px) {
    html { font-size: 1.5rem; }
}
@media (min-width: 992px) {
    html { font-size: 1.75rem; }
}
@media (min-width: 1200px) {
    html { font-size: 2rem; }
}
<div class="container">
    <div class="row">
        <div class="col-md-12">
            <h1>Hello World</h1>
        </div>
    </div>
</div>


<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
like image 170
dferenc Avatar answered Oct 18 '22 08:10

dferenc