You could look into the CSS word-break
property to prevent words/strings being cut in half. If it is specifically line breaks you want to use then appending a class to the element such as <br class="br-on-mobile">
and setting it to display: none
in the CSS should prevent it from doing anything normally.
You can then use a media query to display the line break at specific mobile screen sizes, for example:
.br-on-mobile {
display: none;
}
@media screen and (<Your conditions here>) {
.br-on-mobile {
display: static;
}
}
EDIT: static
is invalid value for display. Using inherit should fix the issue. See this Fiddle
EDIT: The header of your page must also have <meta name="viewport" content="width=device-width, initial-scale=1">
to allow for correct scaling/application of media queries.
You could also achieve this by wrapping the number in a span element and setting this to display: block
when on mobile devices, although your issue with the media queries below will also apply to this.