Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap 3 responsive h1 tag

I am creating a site and want it to be responsive so I am using bootstrap 3. However, the h1 tag on the privacy policy page and about page come out of the container on small mobile devices since the word is too large. Is there a way I can make the h1 tag reduce in size to fit in the container on smaller mobile devices ? The site is muscadinewinerecipe.com if anyone wants to view what I'm talking about. It's the about page and privacy policy page.

like image 719
user2503303 Avatar asked Aug 20 '14 11:08

user2503303


People also ask

Is h1 tag responsive?

it is a responsive theme and the h1 text/site-logo on top remains a large h1 tag when the width is shrunk.

Is Bootstrap 3 mobile first?

With Bootstrap 3, we've rewritten the project to be mobile friendly from the start. Instead of adding on optional mobile styles, they're baked right into the core. In fact, Bootstrap is mobile first.

How do you make a text box responsive in Bootstrap?

You can make text responsive in Bootstrap by using vw units or media queries. The text size can be set with a vw unit, which means the "viewport width". Viewport is the browser window size. 1vw = 1% of viewport width.


2 Answers

You can use this :

CSS :

h1{
     word-wrap: break-word;
     -webkit-hyphens: auto;
     -moz-hyphens: auto;
     -ms-hyphens: auto;
     -o-hyphens: auto;
     hyphens: auto;
}

DEMO : http://jsfiddle.net/ckq04r5q/

Or if you want more browser compatibiliy you can sibling your h1 with id or class and reduce font-size with media query on < 768px

CSS :

@media screen and (max-width: 768px) {
    h1{
        font-size:14px;
    }
}

When your screen as less to 768px of width the property has running

like image 130
Joffrey Maheo Avatar answered Sep 16 '22 21:09

Joffrey Maheo


I've had the same problem, which I've solved with jQuery:

function resize() {
    var n = $("body").width() / 17 + "pt";
    $("h1").css('fontSize', n);
}
$(window).on("resize", resize);
$(document).ready(resize);

The ratio can be adjusted by replacing the value 17 and it can be used for other tags by changing the h1.

like image 30
wirando Avatar answered Sep 16 '22 21:09

wirando