Media Query concerning text for mobile not working

Hi,

I am currently looking into adjusting the text on my website pages so it is more mobile friendly. I am using the standard template from HubSpot named Barricade, and I can see there is already added some Media Query in the css-module, yet it does not seem to work properly:

So far, following is written in the css-module:

@media screen and (max-width: 767px) {
h1 {
font-size: 2rem;

I am really no expert in CSS, so if anyone knows how I can fix it, or maybe just so I can adjust the headings to 30px on mobile devices, I would truly appreciate it.

Thank you!

Hey @Camilla_02

Congrats for tackling some CSS! Hope to see you as an expert around here before long :grin:

Could you paste a link to a page with this on it? We will need some more info before we can help.

Also, that code you have is missing the closing two } .

should look like this:

@media screen and (max-width: 767px) {
 h1 {
 font-size: 2rem;
 }
}

@jonchim , @Chris-M , @BarryGrennan might be able to help you out!

Thank you @dennisedson! It has been a long way coming :sweat_smile:

I can see that I just forgot to attach the closing two } - they are there in the stylesheet.

However, I can see in the css that it is only including the H1, but in general it should include both H1, H2, H3 and so on, maybe that is what went wrong?

Here is a link to one of our websites where it is used: https://www.vitalsmarts.dk/sund-high-performance

Hi @Camilla_02,

You should inspect your page to target your element specifically.

  • The element you want to target is an <h2> element
  • The styling for the element has inline styling. This makes it harder to overwrite.
  • Be carefull with target global html attributes like an h2 because it will apply to all your heading 2 elements. It better to be more specific and add a class or target a wrapper class first.

So what can you do:

- Use the media query with !important

@media screen and (max-width: 767px) {
 h2 {
 font-size: 2rem!important;
 }
}​

- Better option is to target a wrapper element by first adding a class. Then remove the inline styling and apply the custom styling and media query

Hi @Indra

Thank you for your reply - looks like it worked!