Modify the style at the size of the window less or equal (picels)



  • I'm trying to make the blocks. my_media change if the size of the window меньше или равняется 1199px

    I've done it as an example, but the 1199px windows don't change, they're only starting to change in the window at 1198 and lessels.

    I need the styles to change only with a window of 1199 and less peaks.

    I'll be very grateful for your help.

    .my_media {
      margin-top: 120px;
      background: #fff;
      color:#000;
    }
    

    @media only screen and (max-width: 1199px) {
    .my_media {
    margin-top: 150px;
    background: green;
    color:#fff;
    }
    }

    <!doctype html>
    <html lang="en">
    <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    &lt;!-- Bootstrap CSS --&gt;
    &lt;link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous"&gt;
    
    &lt;title&gt;Hello, world!&lt;/title&gt;
    

    </head>
    <body>

    &lt;header class="container p-3 fixed-top shadow-sm" style="height:120px;"&gt;HEADER&lt;/header&gt;
    
    &lt;div class="container my_media"&gt;
      &lt;div class="row"&gt;
        &lt;h1&gt;Hello, world!&lt;/h1&gt;
      &lt;/div&gt;
    &lt;div&gt;
    
    &lt;!-- Optional JavaScript; choose one of the two! --&gt;
    
    &lt;!-- Option 1: Bootstrap Bundle with Popper --&gt;
    &lt;script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"&gt;&lt;/script&gt;
    

    </body>
    </html>



  • Add me to the media request for a shotgun.

    .my_media {
      margin-top: 120px;
      background: #fff;
      color:#000;
    }
    

    @media only screen and (max-width: 1199.98px) {
    .my_media {
    margin-top: 150px;
    background: green;
    color:#fff;
    }
    }

    <!doctype html>
    <html lang="en">
    <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    &lt;!-- Bootstrap CSS --&gt;
    &lt;link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous"&gt;
    
    &lt;title&gt;Hello, world!&lt;/title&gt;
    

    </head>
    <body>

    &lt;header class="container p-3 fixed-top shadow-sm" style="height:120px;"&gt;HEADER&lt;/header&gt;
    
    &lt;div class="container my_media"&gt;
      &lt;div class="row"&gt;
        &lt;h1&gt;Hello, world!&lt;/h1&gt;
      &lt;/div&gt;
    &lt;div&gt;
    
    &lt;!-- Optional JavaScript; choose one of the two! --&gt;
    
    &lt;!-- Option 1: Bootstrap Bundle with Popper --&gt;
    &lt;script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"&gt;&lt;/script&gt;
    

    </body>
    </html>


Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2