Sass - Error: The value provided is not a valid CSS value

Below is the code in my Sass file:

\:root
    @each $name, $color in $colors
        @if type-of($color) == "map"
            @each $subname, $subsize in $color
                --color-#{$name}-#{$subname}: #{$subsize}
        @elseif type-of($color) == "number"
            --color-#{$name}: #{$color}

$colors variable is defined like this:

$colors: (
    accent: (
        darker: #2840d0,
        dark: #2d5ee8,
        base: #2d81e8,
        light: #76b8f0,
        lighter: #b6e1f9
    )
);

An error message I encountered is as follows:

Sass::SyntaxError: (darker: #2840d0, dark: #2d5ee8, base: #2d81e8, light: #76b8f0, lighter: #b6e1f9) isn't a valid CSS value.

This error relates to the line --color-#{$name}: #{$color}.

Answer №1

After conducting some tests, I discovered that the @elseif statement is incorrect. It should actually be written as @else if, with a space between else and if.

One more thing to note is that the quotes around the type are not necessary. Both of these statements will work:

type-of($color) == "map" and type-of($color) == map

Keep in mind that colors are a distinct type in sass, so the final condition may not function as expected. You might consider updating it like this:

@else if type-of($color) == "number"
to
@else if type-of($color) == color

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

The text is placed below the image, rather than appearing alongside it

My website bby is supposed to be displayed right next to the image logo, but it's showing up under the logo for some reason. Can someone help me with this issue? You can view the current layout here This is the html code I have: body { font-si ...

CSS - Problem with background image appearing stretched on Samsung mobile devices

Is the Samsung default "Internet Browser" based on another build? It seems to have trouble displaying stretched background images correctly, unlike desktop browsers or Chrome for mobile. Here is the CSS and HTML I am using: #bk_img { height:100%; ...

Is there a way to implement HTML code that can automatically hide text based on the scroll size, similar to

Check out your Gmail inbox, where you'll notice 3 main columns Includes the sender's information Contains "THE_EMAIL_SUBJECT - THE_EMAIL_BODY" Showcases the date the email was sent on I observed that when resizing the window in the Gmail web c ...

Having trouble resolving this technical problem in Express.js and JavaScript programming

try { console.log('11111') const { data: { tasks }, } = await axios.get('/api/v1/tasks') console.log('22222 ' + await axios.get('/api/v1/tasks') ) console.log('33333 ' + tasks) https://i.sstatic.net/mLLV ...

Utilizing Google Fonts offline without the need for an API

Instead of relying on Google Fonts API to access a variety of fonts for my website, I took matters into my own hands. I downloaded a snapshot of fonts from this GitHub repository: https://github.com/google/fonts and transferred them to my web directory. T ...

Customizing the default image of a Select dropdown field in Sencha Touch

Does anyone know how to change the default image of a select dropdown in Sencha Touch to a customized image? I've attached a screenshot for reference but can't seem to find any properties or classes to adjust this. Any guidance would be greatly a ...

Tips for organizing the Bootstrap elements on an HTML webpage

Struggling to organize a web page with HTML and Bootstrap 4 according to this template? https://i.sstatic.net/BXC3X.jpg <!doctype html> <html lang="en> <head> <title>Hepatrote with Bootstrap v4</title> <meta charse ...

Creating a responsive layout with two nested div elements inside a parent div, all styled

I'm currently facing an issue with using padding in my CSS to make the two divs inside a parent div responsive at 50% each. However, when combined, they exceed 100%. I suspect this is due to the padding, but I'm unsure how to resolve it. .column ...

What's the best way to show black text for progress between 0-40% and white for progress between 60-100%?

As a beginner, I humbly ask for your forgiveness. My goal is to show progress percentages in black and white based on the progress state. Despite my attempts with if statements and creating new classes for black and white progress states, I have not been s ...

Alter the stacking order of a randomly selected element every second

Utilizing an Express server, I am retrieving card data with node-fetch and presenting each one in a div through a loop in an EJS template. By applying CSS properties, I position each card on top of one another at the same location. How can I implement a fu ...

What could be causing the discrepancy in functionality between Safari and Chrome for my overlay feature?

After testing the image hover overlay feature on various platforms such as desktop and Android devices, it has come to my attention that it does not function correctly on Safari. Specifically, the feature does not work on Apple devices like iPhone, iPad, a ...

Get the value of a CSS property in Python by parsing the rendered HTML

Currently, I am using Selenium and PhantomJS in conjunction with Python for the purpose of crawling rendered web pages. While it is a straightforward process to identify the presence of specific words within the HTML content (e.g. if "example" in html...), ...

Remove the footer from the main section

I'm facing an issue with the web page layout of my website. Here is a snippet of the structure: <body> <div class="container"> <div class="sidebar"> </div> <div class="content"> </div> </div> < ...

What is the best way to optimize Bootstrap 5 grids for mobile responsiveness?

Within my portfolio, I have a projects section that switches between having the description on the left with an image on the right and vice versa. Despite my efforts to make it responsive, I'm struggling to figure out how to ensure the image appears a ...

How can I make a fixed background image with NextJS's Next/Image feature?

Lately, I've been exclusively using Next/Image due to Vercel's powerful image optimization service. While I've successfully replaced background-image with DIVs and z-index in most scenarios, I'm facing challenges in achieving two specif ...

Choose the initial unordered list within a specific division through Jquery

In a div, there is a ul. Inside a li, there is another ul. The task is to select only the first ul inside the div using jQuery. The HTML markup: <div class="parent"> <div class="clearfix"> <div class="another-div"> <ul cl ...

How can I select elements in CSS that are "between x and y"?

If I have an HTML table with 20 rows and 3 columns (20x3), I am looking to highlight the rows from 7 to 12 in red. What CSS selector should I use for this specific task? How can I define the range of rows to be styled as "between"? ...

Is there a way to modify the color of my question post-submission?

Within my code, there are numerous queries that need to be addressed. Upon submission, I desire to alter the color of each question to green if the response is correct, or red if it is incorrect. document.getElementById("submit-button").addEventLi ...

Information provided in a login form does not carry over to a different page display

I'm currently facing a problem with my JavaScript code. I have constructed a login form and am attempting to transfer the data from the form to another page where it will be showcased in a table. Regrettably, the details are failing to appear on the s ...

Adjust the width of columns using HTML and CSS

UPDATED: Here is a real-life scenario I am facing: I am trying to adjust the width of columns in my table using inline CSS. Let me provide you with an example: The Table was initially set to 100%, like this: <table width=100% ...> The total number ...