CSS - text featuring a gentle shadow hue and a deeper foreground color

I'm encountering an aesthetic issue where my list of texts have random light/bright colors, making them hard to read on white backgrounds. I've tried setting the text color to shadow, but now I want the text itself to be a darker, more readable color while still maintaining a similar hue to the main light color.

However, adjusting the brightness or using a lower alpha with a black color makes the text appear too greyish for my liking. I am looking for a solution that allows the text to become more saturated as it gets darker, ensuring that the main color remains visible:

or

Is there a CSS blend mode or formula available that can help me achieve one of these desired outcomes?

Answer №1

By utilizing the css functions brightness(0.6) and contrast(200%), I was able to successfully achieve the desired effect. While both values can be altered, I recommend adjusting the brightness alone in order to control the darkness of the text. The contrast value already provides a pleasing color to the darkened text.

Answer №2

I comprehend the requirements you have, however, achieving it efficiently solely with CSS may not be possible. I recommend utilizing Sass .scss along with the following code snippets:

$primary-color: #444;

// define text color function
@function set-text-color($color){
    @if (lightness($color) > 40){
        @retrun #000;
    }
    else{
        @retrun #fff;
    }
}

/* The above function will 
return black if the primary color is light and 
return white if the primary color is dark */

body{
    background: $primary-color;
    color: set-text-color($primary-color);
}

In this snippet, your primary color represents your basic text color. You have the flexibility to customize the function to return a similar color but in a darker or lighter shade based on your design needs.

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 art of CSS Absolute Positioning and the Science of Body Sc

I'm trying to position an absolute div in the bottom right corner of a page. .absolute{ position: absolute; right:0; bottom: 0; } While this code works, I've noticed that when scrolling the page, the right/bottom position is relative t ...

When I hover over my divs, my span is positioned behind them

Greetings, I apologize for any language barriers. I will do my best to articulate my issue clearly. I have experimented with various approaches and reviewed similar questions, but unfortunately, I am unable to resolve the problem... I have created a title ...

Tips on how to horizontally align an icon and text using Material UI

As a newcomer to Material UI, I am facing an issue where my icon and text are not aligned: What I'm aiming for: This is the code I have so far: <div style={{ display: 'inline-flex', VerticalAlign: 'text-bottom', Bo ...

Populate a table cell with a div element in HTML

How can I make a div inside a rowspanned table cell 100% high of the cell? Check out this example for reference: https://jsfiddle.net/gborgonovo/zqohw286/2/ In the provided example, I want the red div to vertically fill the yellow cell. Any suggestions on ...

Combining various arbitrary values, like :has in Tailwind, can be achieved by following these steps

I'm facing an issue where I need to hide an element if it has children. In regular CSS, this is achieved with the following code: &:not(:has(*)){ display: none } However, when trying to implement this in Tailwind, I'm struggling to figure ...

Difficulty arises in designing a tableless layout due to the issue of auto

Wondering why my page is not expanding with its content? Check out my demo on Fiddle http://jsfiddle.net/msas3/. The light blue area should determine the overall height of the page. ...

Ways to style text using variables in SASS without using quotation marks

When working in SASS, I have created the following mixin: @mixin background_gradient($dir, $from, $to) { background: linear-gradient('to #{$dir}', $from, $to); // for IE10 } However, when viewing it in the browser, the output appears as: b ...

Using Jquery to enhance navigation tabs with pointers

I am facing an issue where the class .hover and .over are added to the entire list whenever I mouseover any list item. I understand that this is happening due to my jQuery code, but I would like to find a way for jQuery to only add the class to the specifi ...

The erratic appearance of inactive elements within ExtJS components

I am currently working on an ExtJS form that utilizes hbox-layout containers to generate sentences containing various form inputs. There is a specific requirement to disable the form under certain conditions. These hbox-layout containers consist of compone ...

Change the css code to override the color of the background material

Hey there, I'm facing an issue with overriding the background color of a material element. I've tried several methods but can't seem to get it to change. After inspecting the element on the web browser, I found the CSS code that controls th ...

The jQuery bxSlider is failing to function properly in a responsive design

Anyone else experiencing issues with the jQuery bxSlider not functioning properly on a responsive layout? It seems to be working fine on larger screens. $(document).ready(function () { $('.slider1').bxSlider({ pagerCustom: '#bx-pager&apos ...

Encountering an issue: Integrating JSON data into HTML using Angular.JS!

Having trouble transferring JSON data to HTML using Angular.JS for a programming course. The author doesn't seem to have this issue, can anyone provide some assistance? I've correctly linked Angular and added the app, but it's not working a ...

What is the best way to align a div of variable size in a container of variable size using CSS?

My website features a 3-level structure that consists of a "workingArea" and an "imageContainer" within it, containing an image. <div class="workingArea"> <div class="imageContainer"> <img class="theImage" /> </div> </div> ...

Using HTML to create interactive table cells

I am looking to add functionality to make a cell in an HTML table clickable. When this action is triggered, I want a pop-up or window to appear with specific information. Below is my current HTML code: <table class="table1"> <thead> <tr ...

Tips for Choosing Certain List Items in a Responsive Bootstrap Navigation Menu for WordPress

I've put together a sleek bootstrap navbar menu for WordPress. If you want to check out the menu design, you can view it by clicking on this link: here There are still some tweaks that need to be made though. Specifically, I need to add a box around ...

Tips for implementing validation in JavaScript

I'm brand new to learning Javascript. Recently, I created a template for a login page and it's working perfectly fine. However, I am struggling with setting up validation and navigation. My goal is to redirect the user to another page if their us ...

Today, I am experimenting with HTML5 File Upload using Capybara and Selenium Webdriver in Ruby

I have encountered a problem with a simple modal that allows users to upload a file using a browse button. Due to some unknown issue, possibly related to the fact that it is an HTML5 file input and the browser adds its own functions to it, testing this has ...

Spinning an SVG circle using a group element

I'm interested in rotating an SVG circle without affecting the rotation of other elements. My attempt to rotate the white circle using rotateZ(15deg) resulted in this: This is the progress I've made so far: https://jsfiddle.net/41hrnojs/ <sv ...

Ensure the header remains fixed when scrolling in an HTML page with Bootstrap

I created the following code. However, when I scroll down the table, the header disappears from view. I would like the header to always remain at the top, even when scrolling. Despite searching Google multiple times and trying various solutions, I have no ...

What is the best way to alter the header in Django when a user is authenticated?

In my project, I have two headers: header.html and headersuccess.html. When a user is logged in, I need to change the header from header.html to headersuccess.html. How can I implement that? Here is an excerpt from my views.py file where I render loginsuc ...