CSS3 variables causing issues

I want to streamline my CSS file by setting up generic variables that can be used throughout to ensure consistency and organization.

For example:

@shadow: 6px 6px 10px rgba(0,0,0,0.2);

.shadow {
    box-shadow: @shadow inset;
}

However, when I try to apply .shadow to an element, the shadow does not appear on the page. Upon inspecting the Elements in Chrome, I notice that .shadow is crossed out with the message "Invalid property value".

This issue extends beyond just shadows; it also occurs with properties like width and height.

I have seen similar setups work perfectly fine on JSFiddle pages in the same browser, so I don't believe the problem lies with the browser itself.

Answer №1

When it comes to declaring variables, CSS pre-processors such as LESS or SASS are the way to go. Unfortunately, CSS3 does not support variable declaration rules.

If you're seeing variables in your JSFiddle pages, chances are you have included these pre-processors which could be causing some confusion.

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

Using display:inline-block will increase the vertical spacing

I am currently dealing with the following HTML and CSS setup: * { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } body { margin: 0; } .row { background-color: red; /* display: inline-block; */ } ul { ...

Having trouble getting padding to work inside a pre block, even when using a wrapper div?

Snippet of HTML Code: <div class="prewrap"> <pre> stepsize = .01 samplestimes = 30 universex = seq(-1, 1, stepsize) universey = sin(pi * universex) </pre> </div> Sample CSS Styles: #prewrap { background-color: #e3e3e3; pa ...

Creating a custom breakpoint in Bootstrap for adding unique CSS styles

Consider this scenario <div class="col-md-my"> </div> .xx { color: black; } .yy { color: red; } Similar to how Bootstrap adjusts width at different breakpoints. Create a new class called col-md-my When the width exceeds the ...

How to make your divs stand out using Bootstrap

Can anyone assist me in aligning my divs based on the example below? Here is what I have achieved so far: I am struggling to apply spacing between the two divs, and they are not of equal height. My HTML: <div class="container - fluid"> ...

What is the best method for utilizing the jQuery Selector in this particular web application?

I have been attempting to figure out how to select a delete icon within my personal web application. delectIcon HTML <main> <div class="container"> <div class="tabs"> <a href=""><p><span class="act ...

Utilizing Sass variables and customizing CSS styles within the main stylesheet

Hey there! I'm new to sass and I have a specific question about it. Do I need to link the scss file to a separate css file where I'm working, or can I write my styles directly in the same file? I tried using sass variables from Bootstrap 5.3.2, b ...

What causes the odd gaps at the bottom of boxes in a Pure CSS Masonry layout?

Issue with implementing Pure CSS Masonry layout. Using position: relative for the boxes and position: absolute for the content inside each box is causing gaps below each box. Struggling to find a solution, view the code on this codepen: http://codepen.io/k ...

compress a website to display advertisement

Here is a JSFiddle link I would like to share with you: I am currently working on squeezing the webpage to display an ad on the right side. http://jsfiddle.net/5o6ghf9d/1/ It works well on desktop browsers, but I am facing issues with iPad Safari/Chrome ...

Steps to customize the error icon in Material-UI Stepper

I am faced with the task of changing the error icon of a default MUI Stepper, which currently looks like this: https://i.stack.imgur.com/jZlOn.png However, I need it to display the following icon instead: https://i.stack.imgur.com/uTGSw.png Although I am ...

Is it necessary to have uniform spacing between links in a responsive navigation menu?

I am attempting to create a horizontal menu navigation system. I have multiple links in the navigation, and my goal is to evenly space them horizontally. Is there a way to achieve uniform spacing between links in a horizontal menu? HTML: <div id= ...

What steps are involved in building a modal pop-up in Angular without using any pre-existing libraries

I am looking to create a modal popup when a button is clicked. I want to achieve this without relying on any additional dependencies. The method I have used below successfully creates a fully functional modal, but I am unsure if this is the best way to do ...

Conceal the ::before pseudo-element when the active item is hovered over

Here is the code snippet I am working with: <nav> <ul> <li><a href="javascript:void(0)" class="menuitem active">see all projects</a></li> <li><a href="javascript:void(0)" class="menuitem"> ...

Using Jquery to determine if a div is empty, excluding any content before or after it

I'm looking to use JQuery to determine if a Div is empty without taking into account any content added before or after it. When checking for emptiness, I want to ignore anything placed before or after the div. $(function(){ if($('#content&ap ...

Are there any Bootstrap 4 classes that have the "cursor:pointer" style other than "btn"?

I am currently utilizing the Bootstrap cards class for my project and I am trying to achieve a cursor pointer effect when hovering over certain cards. However, I prefer not to resort to using the style attribute and only want to utilize Bootstrap classes ...

How can CSS files be shared among multiple projects within Visual Studio 2012?

I am working on a Visual Studio Project Solution that includes 3 separate projects. To streamline the process and avoid duplication, I aim to have a shared CSS file for all 3 projects since they all follow the same CSS rules. Despite trying the Add As Lin ...

What is the best way to develop an expanding line animation from this starting point?

I have a vision for an animation where, upon hovering over an icon, it enlarges, increases in opacity, and reveals some accompanying text. The visual effect I am aiming for involves two lines of color expanding horizontally from the center outwards before ...

Customize material-ui button designs using styled-components

I'm currently facing an issue with overriding the border-radius of a material-ui button using styled-components. Despite setting it to 0, it's not taking effect. Here is the code snippet: import React from "react"; import styled from "styled-co ...

What occurs when Render() is called during animation in React?

Curious about how React handles rendering during a component's animation? Let's explore an example where a component is re-rendered due to a state change triggered during its animation. Imagine a scenario where a component's animation lasts ...

Why Isn't This JPG Image Functioning Properly in HTML/CSS?

I am facing an issue with a JPG image that I am attempting to use in CSS as a background-image for a div container. For some reason, this particular image refuses to render in the viewport. Interestingly, when I inspect the element, I can see its thumbnail ...

Transitioning the width in CSS without using the "auto"

Currently, I am experiencing a problem with my CSS animation that is leaping directly from the start to finish. It appears to be connected to a similar issue addressed in this thread. My inquiry is: Is there a way to create a smooth transition in width f ...