I would like to set label size the same as screen size.
f.e. for large screen large label, for small screen small label.
Simply add a font-size: 8px; to your CSS selector. Replace 8 by any number you wish to change your font-size to.
Because Bootstrap 4 uses rem for the font-size unit of most of it's elements, you can set the font-size in px on the HTML element in your own stylesheet and this will change the default sizing Bootstrap applies to your elements.
In Bootstrap 3 they do not have separate classes for different styles of labels.
http://getbootstrap.com/components/
However, you can customize bootstrap classes that way. In your css file
.lb-sm { font-size: 12px; } .lb-md { font-size: 16px; } .lb-lg { font-size: 20px; }
Alternatively, you can use header tags to change the sizes. For example, here is a medium sized label and a small-sized label
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/> <h3>Example heading <span class="label label-default">New</span></h3> <h6>Example heading <span class="label label-default">New</span></h6>
They might add size classes for labels in future Bootstrap versions.
You'll have to do 2 things to make a Bootstrap label (or anything really) adjust sizes based on screen size:
.label { font-size: 75% }
. So any extra selector on your CSS rule will make it more specific.Here's an example CSS listing to accomplish what you are asking, using the default 4 sizes in Bootstrap:
@media (max-width: 767) { /* your custom css class on a parent will increase specificity */ /* so this rule will override Bootstrap's font size setting */ .autosized .label { font-size: 14px; } } @media (min-width: 768px) and (max-width: 991px) { .autosized .label { font-size: 16px; } } @media (min-width: 992px) and (max-width: 1199px) { .autosized .label { font-size: 18px; } } @media (min-width: 1200px) { .autosized .label { font-size: 20px; } }
Here is how it could be used in the HTML:
<!-- any ancestor could be set to autosized --> <div class="autosized"> ... ... <span class="label label-primary">Label 1</span> </div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With