Diversify Your Color Palette with Sass Color Functions - Utilize Multiple Functions

Looking to make adjustments to a HSL color in one go, including hue, saturation, and lightness. I've tried applying each adjustment individually like this:

$color: hsl color code;

$new-color: adjust-hue($color, -1);
$new-color: lighten($color, 20%);
$new-color: desaturate($color, 10%);

However, the changes aren't being applied correctly. Is there a way to create a function or mixin for this task to keep it clean and ensure proper behavior? Thanks!

Answer №1

First things first, the issue in your current code is that you are making updates to the variable $new-color using the $color variable in each step, which is not correct.

If you want to adjust hue, saturation, and lightness simultaneously, then you should utilize the adjust-color() function (Check out the documentation).

For instance, here's an alternative way:

$color: hsl(120,100%,50%);

$new-color: adjust-hue($color, -1);
$new-color: lighten($new-color, 20%);
$new-color: desaturate($new-color, 10%);

This can also be achieved like this:

$color: hsl(120,100%,50%);

$new-color: adjust-color($color, $hue: -1,$lightness: 20%, $saturation: -10%);

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

Combining 1 pixel borders to create a bolder border effect

How can I prevent the border from becoming 2 pixels when I have overlapping (touching) divs? I thought about putting borders on only 2 sides, but then one edge of the div would be without a border. By the way, I am utilizing jQuery Masonry. ...

Interactive Image Carousel Using <ul> and <li> Tags

I am facing an issue with my image gallery slideshow using <ul> and <li> in HTML and CSS. The problem is that it is not responsive on mobile devices, as evidenced by the link provided herehere (I am accessing it from a smartphone). In the ima ...

The Bootstrap navbar functions flawlessly in full screen mode, but encounters issues when condensed

My bootstrap navbar looks great in full-screen mode, as shown here. However, when the screen size is reduced, bootstrap automatically stacks the items, leading to an undesirable layout with Register and Login on the same line, as seen here. I am looking ...

Change the width of a div element without causing text to wrap when resizing the browser window

Looking to create a layout with three div elements, each containing an h1 element. The goal is to have the first div on the left side, the second div in the center, and the third div on the right side, all in a single row. When the window is resized for re ...

Adjusting badge width in Bootstrap v5 for fixed positioning

Is it possible to have a button with a notification badge that maintains a consistent size regardless of the number displayed? <button class="btn btn-orange w-75 fs-4 mb-3 position-relative"> Next Round <span class=" ...

Dropdown search menus are failing to appear in the correct location

I have 4 dependent search dropdown menus side by side. There are two issues I am facing: Whenever I type in any of the drop-down menus, the MySQL-connected lists appear but not directly beneath the actual 'input-type-search-box'. Additional ...

Limit the maximum height of a list within a fluid-width content container

I came across this link The layout works fine when the elements are limited in the #commentWrapper, but adding more items pushes everything downwards. Copying additional <li>test</li> items clearly demonstrates the issue. I want the input box ...

Utilize HTML/CSS for text that changes automatically

Is it possible to dynamically change text using HTML and CSS based on the page being viewed? For example, when on the home page, the text would automatically display "Home Page" without needing manual changes on each page. I want this process to be seamles ...

Struggling to eliminate the padding beneath the menu items in Bootstrap?

I'm having trouble adjusting the padding inside my menu. I want to make it less chunky and large, but so far I've only been successful in removing the top padding. The bottom padding just won't budge. Here's the code that helped fix th ...

Tips for redesigning your Bootstrap slider

Looking to update the carousel design for the previous and next buttons with a new look. I've attempted the following code: .carousel-control-prev { content: 'prev'; font-size: 55px; color: red; } <a class="carousel-control-next" ...

Identify certain lines from the paragraph text

Suppose you have an HTML Paragraph Element (e.g., <p>) with certain text sections highlighted using a HTML Mark Element (e.g., <mark>). I am interested in adding a vertical line in the margin or gutter (uncertain about the appropriate term) tha ...

What is the best way to make the first LI elements stand out in a nested structure by applying bold

I had an idea like this: #list li > a { font-weight: bold; } However, I only want the top level items to be made bold, not nested LI's within LI's -- hope that makes sense?? :) EDIT | <ul id="list"> <li><a href="#"& ...

Ways to focus on TinyMCE editor for customization

Would it be possible to target the entire TinyMCE editor in order to apply some styling, such as adding 10px of padding around it? I'm using TinyMCE 4 and starting with the HTML code shown below results in TinyMCE generating additional HTML. I would ...

Omit one element from the margin configuration for the navigation bar

I need help excluding the margin setting for just one item in my navigation bar, specifically the last one labeled "Kontakt" Here is the HTML code: <nav> <ul> <li><a href="index.html">HJEM</a></li> ...

How to remove an event listener that was added within a function in JavaScript?

I am encountering an issue while trying to remove an event listener that was created inside a function. Oddly enough, it works perfectly when I move the event listener outside of the function. See the example below: <body> <div id='myDiv&apo ...

Is your Chrome DevTools changing CSS Link files to "Constructed Stylesheet" after you edit the CSS using Inspect Element? Find out how to fix this issue!

This issue relates to CSS files that are initially not identified as constructed stylesheets but end up being displayed as such after editing, rendering the file inaccessible. Specifically in Google Chrome DevTools (last observed in Chrome 86): Whenever ...

Tips for creating a static header div with a fixed size and a scrollable body

Check out the code snippet below as a reference: <div class="main"> <div class="header"> Header<br> Header<br> Header<br> Header<br> Header<br> Header<br> Header<br> Header<br> Header<br> He ...

Is there a barrier I've reached with the amount of hashtags I'm using?

My goal is to limit the use of javascript and rely more on CSS to achieve desired effects on my website. One feature I have developed is a modal that opens using hashtags and targets, similar to this example: http://codepen.io/maccadb7/pen/nbHEg. While th ...

Overlapping spans

I am trying to stack these spans on top of each other without much success, http://jsfiddle.net/76NNp/79/ <td class="rtf hov"> <div>Investment</div> <div class="mub eub"> <span style="float:left">Test</spa ...

Why is having <html lang="en"> essential?

Is the tag essential for website development? Will my code be impacted if I choose not to include it? ...