The CSS media query isn't working as expected

Having some trouble with media queries on a physician website I'm developing. I've tried multiple times but can't seem to figure out why they aren't working. If anyone could take a look and offer some guidance, that would be much appreciated! Here's the link to the codepen: https://codepen.io/Razu381/pen/XQJVzg

@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {

body{
    font-size: 15px;
}

.slide-text h4{
    font-size: 25px;
}

.slide-text p{
    font-size: 16px;
}

Answer №1

Your code had the issue of missing closing brackets in the media query section.

and (min-device-width : 320px)
and (max-device-width : 480px) { <- This marks the beginning of the media query

body{
    font-size: 15px;
}

.slide-text h4{
    font-size: 25px;
}

.slide-text p{
    font-size: 16px;
}<- The end of slide text p

<- The media query does not have a closing bracket

Answer №2

Everything should function exactly as anticipated.

@media only screen
and (min-width : 320px)
and (max-width : 480px) {

    body{
        font-size: 15px;
        }

        .slide-text h4{
            font-size: 25px;
         }

        .slide-text p{
                font-size: 16px;
        }
}

Answer №3

There seems to be a syntax error. You are missing a closing curly brace }.

@media only screen and (min-device-width : 320px) and (max-device-width : 480px) {

  body{
      font-size: 15px;
  }

  .slide-text h4{
      font-size: 25px;

  .slide-text p{
      font-size: 16px;
  }
}

Answer №4

Make sure to include the closing bracket } at the end of your code in order for it to work properly.

@media only screen and (min-device-width : 320px) and (max-device-width : 480px) {

     body{
        font-size: 15px;
     }

     .slide-text h4{
        font-size: 25px;
     }

     .slide-text p{
        font-size: 16px;
     }
}

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

Tips on positioning a div based on the screen dimensions

In my table, there is an icon that reveals a chart as a popup when hovered over. This div is where the chart is displayed: <div id="chart-outer" style="@style" class="popup-chart close"> <h2 id="charttitle&q ...

Having difficulty implementing Jquery UI effects within an HTML Dialog in Google Apps Script

Looking for a scrolling effect in an HTML Dialog with Google Apps Script. I've already tried this link and placed the code in the editor. However, when highlight buttons are clicked, they work but do not cause scrolling within the HTML dialog. < ...

A <div> with 100% height nested within a full-page div positioned at top:0 and bottom:0

Here's a simple problem. I need a full-height div (#inner) inside another full-height div (#outer, but with padding). This code displays correctly in Firefox and IE8, but not in IE7 and IE6. Edit: In the specific context where I'm using this s ...

inadequately arranged in a line

In Bootstrap 4, I have created this form group that you can view in this fiddle: <div class="m-portlet__body"> <div class="form-group m-form__group row"> <label class="col-lg-2 col-form-label"> Email Address ...

It vanishes as soon as you move your cursor away during the animation

I created a button component with text animation, but I'm encountering an issue. When I hover over the button, the animation works smoothly. However, if I quickly move my cursor away or unhover in the middle of the animation, the text disappears unex ...

Tips on adjusting the color of a chosen tab using the CSS :target Property, no JavaScript needed!

I am currently attempting to modify the color of the active tab using CSS and the :target property. The issue I am facing is that I am unable to identify the clicked tab when using the :target property. Therefore, I would like the active tab to be visible ...

Creating a gallery layout using Flexbox that maintains the aspect ratio of images of varying sizes

I've been working on creating a gallery layout using flexbox similar to this design: Example of desired outcome The goal is to have images displayed in two columns next to each other, resizing to the size of the largest image without distortion. On m ...

Using Bootstrap columns within a PHP while loop

Encountering an issue https://i.sstatic.net/twePb.png and the code in question is shown below: <div class="col-md-4 text-center animate-box"> <a href="work-single.html" class="work" style="background-image: url(images/port ...

Can JQuery be used to specifically target attributes with vendor prefixes?

Is there a way to change the Thumb color for my slider without needing to select the thumb with a vendor prefix? I want to be able to dynamically pick the color without simply appending a class. $('.button').on('click', function (e) { ...

Creating an inclusive h1 header with a logo: A step-by-step guide

Is there a way to have a logo linked to the homepage and also have an h1 element that is invisible? This is my current layout: <header id="pageHeader"> <h1> <a href="<?php bloginfo('url'); ?>"> & ...

What could be causing the CSS height percentage to malfunction?

I'm having trouble with some basic CSS that uses percentages. I've labeled everything and checked my code, but it still isn't working properly. Here's the CSS code snippet: .BoxHeight { height: 100%; } #Box { margin-top: 0%; mar ...

Tips on how to prevent a video from playing in the background of a popup even after it has been closed

After creating a video popup that plays upon clicking a button using jQuery, I encountered an issue where the video continues to play in the background even after closing the popup by clicking the close(X) button. Below is my code, can someone assist me in ...

Using a simulation to deactivate webpage elements and showcase the UpdateProgress control

I am currently attempting to disable certain page elements and display an update progress control in my application. In order to achieve this, I have applied a style sheet with the property filter: alpha(opacity=85); However, I encountered an error stati ...

Dimension of the element that has been positioned absolutely

One of my challenges involves working with an absolutely positioned div element (.tooltip) containing another div (.text) that has text with a set max-width. The issue arises when the left property of .tooltip is too large, causing its width to shrink du ...

Which option is more effective: using an id or using !important?

While some say to avoid using the !important rule and others argue that since ids are unique, there is no need to target like #main > #child and you can simply use #child. In my particular case: #main > div{ color: red; } #child{ color: blue;/ ...

Issue with z-index in Internet Explorer version 7

Currently, I have implemented a drop-down list using jQuery that activates when the user hovers over the main menu. This functionality is working appropriately in all browsers except for IE7 and earlier versions. In an attempt to ensure the drop-down menu ...

The color of the Angular md-switch .md-thumb is not showing up properly when switching the toggle

In Safari, the md-switch displays a yellow section on the md-thumb when toggled. However, other browsers handle the switch without any issues. The md-bar appears fine, but the md-thumb is yellow. I have tried setting everything to the blue color I am using ...

What is the best way to incorporate a minimum width and maximum width in CSS that add up to 100% when necessary?

Can anyone help me find CSS rules that can set a fixed width for an element (width: 500px) but also allow it to be responsive with max-width: 100% if the container is narrower than the element? I saw this example and it works perfectly: .elem { width: 60 ...

How to stop the overflow scrollbar in a grandchild element with CSS grid

Encountered an unusual issue while using a combination of CSS grid and overflow auto. In the scenario where there are 3 elements, the outermost element has display: grid, the middle element has height: 100%, and the innermost element has both height: 100% ...

When utilizing narrow resolutions, header letters may overlap each other

As I integrate bootstrap into my website, I've noticed that when the resolution is narrow, my header overlaps. If the header is of a small size, like the typical H1 size, everything looks fine. However, when using a larger size (see CSS below), the is ...