Is it achievable to establish both a maximum and minimum font size and maintain responsiveness when scaling?

Currently, I am using the following CSS class:

.md-subheader-title {
    // 22 pixels
    font-size: calc(12px + 2vw); 
}

While the font size is 22 pixels at max screen size, it reduces to less than 14px on mobile devices. Is there a way to make it responsive so that it ranges between a maximum of 22px and a minimum of 14px?

Answer №1

Implement a media query to enforce a specific font size on smaller viewports.

In this scenario, ensure the font size does not go below 14px. This will occur when calc(12px + 2vw) is smaller than 14px, or when 2vw is less than 2px; typically on screens narrower than 100px.
(These are extremely narrow screens, just so you know.)

.md-subheader-title {
    /* 22 pixels */
    font-size: calc(12px + 2vw); 
}

@media all and (max-width: 100px) {
  .md-subheader-title {
    font-size: 14px; 
  }
}
<div class="md-subheader-title">
This font is adjustable within certain limits.
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to customize the size of a file upload Buefy component to have both a specific

I am looking to set up a file drop area with the Buefy component, but I want the size of the drop area to be 100% of both the width and height. The basic page is provided below, however, I am unsure about where to add the necessary width and height styles. ...

For JavaScript to run, it must be included in the HTML document and invoked externally using the <script src=...> tag

When it comes to my JavaScript code, I've encountered an interesting scenario where it only seems to run properly when it is both included in the HTML file and called externally like so: <script type="text/javascript" src="{{ url_fo ...

What is the best way to eliminate a vertical line from an HTML table?

I am looking to remove specific vertical lines from an HTML table. There are only 3 vertical lines in total, and I want to remove the first and third lines. Below is my code: <html> <head> <style type="text/css"> .table1{ background: ...

Utilize AJAX to showcase JSON data retrieved from a specified URL

We are striving to showcase the names listed in our JSON file within a div using JavaScript. Despite multiple attempts, we have not yet achieved success. JSON data: This is the approach we took: <button>fetch data</button> <div id="result ...

Struggling with finding the correct classes to target in my SCSS files

Within my project lies a section designed to showcase items in a CSS grid format similar to this: View the grid with its items here The markup I used is as follows: <section class="section-b py-2"> <div class="container"> <h2 class= ...

Nav bar width remains stagnant despite varying content lengths

My navigation bar looks great with 5 objects, but as soon as I add 3 more, it suddenly drops below the main header. Why is this happening? 5 Objects: 7 Objects: HTML: <div id="header"> <div class="w960"> <div id="logo"> ...

Is there a method for converting HTML/CSS into an image file?

My issue involves an unordered list (<ul>) with styled list items (<li>) that may have their properties changed through CSS manipulation (such as adding a different background on click using jQuery). I am currently using the TCPDF library to g ...

What's the reason for the malfunction of  ?

How can I add space between firstname and lastname using   in my code? Despite setting the character set to utf-8, the space is not being rendered correctly. I even tried using tab space, but it didn't work as expected. export class AppCompone ...

Bootstrap Overlapping Problem: Find a Solution

Currently, I am in the process of learning how to create a responsive website using bootstrap. Although I have been making progress, I realize that my code may not be as clean as it could be. However, my current concern revolves around overlaying an image ...

What is the best way to add angular's ui-sref directive to a link element?

I am currently using AngularJS for one of my app and came across an interesting scenario in one of my views: <span>My URL: <a ui-sref="mystate({ arg1_name: 'arg1_val', arg2_name: 'arg2_val'})">XXX</a></span> Ev ...

Is there a method to customize the behavior of an element with a subclass when the :hover event is triggered?

How can I apply different styling properties when hovering over a selected option with the class ".form-option-card" and ".form-option-selected"? By default, unselected options only have the class form-option-card, while the selected option includes the fo ...

Enhancing the menu/navigation bar with individual AJAX loaders

I have chosen the Vivant Designs theme for our website, which can be found at What I am looking to achieve is an ajax loader that will appear next to the link or tab when a user clicks on a link within the drilldown menu located on the left side. The cont ...

Ember's distinctive feature: Named Block Helpers

Can we create "named blocks" in a different way? For instance, {{#customBlock "repeatableBlock"}} {{!-- block containing numerous properties and data that may become messy if hardcoded multiple times --}} {{/customBlock}} Then, elsewhere in the code, {{ ...

Create equal height card headers in Bootstrap4

Imagine a scenario where you are using Bootstrap 4's pricing template and the card headers have varying text lengths, causing their heights to differ under certain screen resolutions. The challenge is to ensure that all card headers maintain a consist ...

What is the best way to create a dynamic component from scratch?

There's a captivating Animated Scrolling feature in the hero section of this particular website. I'm interested in learning how to recreate this component and implement it with tailwind CSS. Could you please check out the provided link for refere ...

Having trouble getting jQuery .click to trigger on a dynamically loaded button?

I'm having some trouble with my code. I have a list that loads dynamically with a button inside, and although I have set up jQuery to handle the click event, nothing is happening. Here's a snippet of the code: HTML: <ul id="cart"> ...

Upon refreshing the page, Vuex encounters an issue where it is unable to read

My website has a Navbar component that utilizes values from the Vuex store. Prior to entering each route, I trigger a dispatch from Vuex as shown below: router.beforeEach((to, from, next) => { //... store.dispatch("updateUserData"); ...

JavaScript/jQuery creation of a dynamic breadcrumb trail linked to the current page

After reviewing the question posted here, the answer seemed adequate for static navigation but lacks functionality for actual user navigation. I am in need of a custom Javascript/jQuery script that can dynamically generate breadcrumbs based on the URL of ...

Inventory with complete rationalization

I'm in the process of creating a basic HTML list where the text within the list items is fully justified. Here is the list that I want to justify: <p style="text-align: center;"><strong>Attention Restoration Theory</strong> ...

CSS Trick: How to Clear Content in a 3-Column Div arrangement

I've been struggling to clear the content below my three div columns, each consisting of a span with centered text and a textarea. It seems that the issue arises from the floating div tags without proper clearing. When viewed in Firefox, the next ele ...