Sass - Trouble with Media Queries in Jekyll

My website was created using Jekyll and Sass. I attempted to make the site responsive, but for some reason, the media queries are not affecting the div class.

This is my style.sass snippet:

.img-link
    width: calc(32% - 14px)
    border: 2px solid white

@media (max-width: 700px)
  .img-link
      width: calc(97% - 14px)

I am utilizing Sass on a mixin in a Jade file:

mixin img(link, img, color)
  a(href="#{link}").img-link

Here is the compiled CSS:

section.notes .img-link {
    width: -webkit-calc(32% - 14px);
    width: calc(32% - 14px);
    border: 2px solid white;
    @media screen and (max-width: 700px) {
      section.notes .img-link .img-link {
        width: -webkit-calc(97% - 14px);
        width: calc(97% - 14px); } }
    section.notes .img-link img {
      width: 100%; }

@media (max-width: 700px) {
  .img-link {
    width: -webkit-calc(97% - 14px);
    width: calc(97% - 14px); } }

This is the compiled HTML:

<head>
    <link rel="stylesheet" href="/assets/css/main.css">
    <script src="//code.jquery.com/jquery-2.1.4.min.js"></script>
  </head>
  <body>

<section class="notes">

<div class="flex flex--center">

<div data-orig-color="#ea4c89" class="col-3 flex flex--center dribbble">

<div class="col-3">

<p class="home-lead">...Updating...</p>
<a href="#" data-color="orange" class="img-link"><img src="assets/img/design-img/drib-1.jpg"/></a>
<a href="#" data-color="#aeb3b0" class="img-link"><img src="assets/img/design-img/drib-2.jpg"/></a>

Answer №1

Upon examining the CSS that was generated, it is evident that section.notes .img-link holds more specificity and would override .img-link within the media query.

It is crucial to ensure that the selector within the media query is at least as specific as the one outside of it.


Upon further review, the generated CSS reveals the following selectors:

section.notes .img-link
    width: calc(32% - 14px);

@media screen and (max-width: 700px) section.notes .img-link .img-link
    width: calc(97% - 14px);

section.notes .img-link img
    width: 100%;

@media (max-width: 700px) .img-link
    width: calc(97% - 14px);

Without the context of the HTML structure, it is challenging to determine which of these selectors actually apply the styles in question. However, it appears to be a problem related to specificity...

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

Modify the file names during the upload process and remove chosen files from multiple directories

I have written some code and my question is how can I rename a file while uploading it and also include the file size in the upload process so that I can fetch the file size in my report as well. <?php if ((!isset($_GET['admin'])) and (!is ...

a new webpage beginning from a different location

Starting from scratch here, I must apologize for not providing any code upfront. The issue at hand is this - I've got a page full of information sorted by ID (retrieved from the database). These IDs are linked from another page where users can click ...

How can I implement a search box on my HTML website without relying on Google Custom Search?

Greetings to all! I am currently managing a website filled with HTML content. I am looking to incorporate a search box into the site. After researching on Google, most of the results point towards using Google Custom Search. However, I require a search box ...

How do I implement a scroll bar for a specific section on a webpage?

After finding the solution to this particular question, I encountered a similar issue on a different page. <div style="white-space: nowrap;"> <span style="display: inline-block; width: 280px">...</span> <span style="display: ...

How can I customize the appearance of a specific tagged page on my Tumblr blog?

Although I have a solid grasp of HTML & CSS, I am encountering some difficulties with the Tag Page feature on Tumblr. Specifically, I want to change the heading displayed on the /tagged/vld tag page without altering the URL. Currently, the heading is gener ...

How to perfectly align content on a webpage

Can someone help me understand why my webpage is off-centered as it scales up? I have set a minimum width of 1000px, but it still appears to be centered at 30%-70%. Any insights on this issue would be greatly appreciated. <!DOCTYPE html PUBLIC "-//W3 ...

Adjust the color of the hyperlink within the Lightbox feature

I am currently using Lightbox Plus. I made some changes to the link colors in the Lightbox.min.css file: .lightbox a{ color: #E74C3C; } .lightbox a:hover{ color:white; } .lightboxOverlay a:{ color: #E74C3C; } .lightboxOverlay a:hover{ color:white; ...

The grid area may not properly adjust based on the width size of the browser

When adjusting the width of your browser, you may notice occasional white space in the bottom right corner. https://i.stack.imgur.com/UFV6R.png https://i.stack.imgur.com/VfhMN.png Is there a way to remove this extra margin? In other words, how can I ens ...

What is the best way to center a div horizontally on all screen resolutions using only CSS?

The margin: 0 auto declaration is not having the desired effect for some reason. I have attempted using text-align in the header, as well as exploring various other options, but none seem to be working. This is my current code: div.middle { font-fami ...

Navigating to the Top of the Page

I am facing an issue with my webpage that is similar to the code provided below: var btn = document.getElementById('test') test.addEventListener("click", function(){ window.scroll(0,0) }) .wrap { overflow-y: scroll; position: absolute; ...

How can I position a div column-10 to the right and make it stay fixed in place

I'm having an issue trying to position a div on the right side without causing content to overlap with the navbar. I've attempted using `position:absolute top:0 right:0`, but it's not working as intended. <link href="https:// ...

Align images of varying sizes vertically within div containers, even when the image is larger than the div itself

I'm facing a challenge when it comes to aligning images vertically inside divs. The problem arises due to the following conditions: The images will have varying and unknown sizes. These images are larger than the divs they are contained in, requiri ...

Why Isn't the Element Replicating?

I've been working on a simple comment script that allows users to input their name and message, click submit, and have their comment displayed on the page like YouTube. My plan was to use a prebuilt HTML div and clone it for each new comment, adjustin ...

What is the best way to make this CSS arrow see-through?

My goal is to achieve this desired outcome: https://i.sstatic.net/4eTpE.png Currently, I have the following (focusing only on the left element for now): https://i.sstatic.net/nUFp1.png I am struggling to make the left arrow transparent and I can't ...

CSS tricks: Make triangles stand out with unique hover effects

I find myself in a bit of a conundrum! I want to incorporate cursor: pointer into my CSS, but the issue is that it's for a triangle shape. If I were to use the following code: #triangleholder { width: 100px; height: 100px ...

What is the best way to make IE 10 display a pointer instead of an I-bar for a select list?

Is there a way to make IE 10 display a pointer instead of an I-bar when selecting from a list? Despite trying various methods found in similar questions, I have been unable to resolve this issue. The cursor: pointer property works as expected on other br ...

What is the reason that root elements of stacking contexts do not stack when their properties are different?

Today, I encountered a surprising scenario where an element with a transform property that was not set to none failed to stack above another element with a position of absolute, despite having a higher z-index. However, adding either position:absolute or p ...

"Struggling to horizontally center a div with a fixed width in CSS - what am I

Whenever I try to use it on my browser, the content shifts to the left and I can't seem to center it using text-align or flexbox. The issue gets resolved when I remove the width property, but I really need it to have that paragraph-style look I'm ...

HTML is not connecting to CSS

I'm having trouble linking my external CSS to my HTML file. In the head of my index.html, I have this code: <head> <title>Twenty by HTML5 UP</title> <meta charset="utf-8" /> <meta name="viewport ...

Calculation of image size in JQuery fails to function properly on Chrome and Safari browsers

CONCEPT This page features a combination of visible and hidden div elements, with the hidden ones becoming visible upon clicking a specific span element. One of these hidden elements contains multiple images with overlaid text that are randomly positioned ...