The concept of CSS background layers: applying color opacity to the upper layer

Utilizing color opacity with rgb has been a challenge for me. I frequently encounter the issue of not having the desired background underneath it, and I am unable to add additional HTML or pseudo elements to serve as backgrounds for the opacity.

Therefore, my solution approach involves exploring the use of CSS multiple backgrounds.

My ideal first layer background is rgb(0 0 0 / 74%).

I would like to have a gradient var(--gradient) fixed below it, so that the opacity from the rgb is applied to the mentioned gradient.

Answer №1

background: linear-gradient(rgb(0 0 0 / 74%), rgb(0 0 0 / 74%)), var(--gradient) fixed

background-color does not allow for multiple backgrounds, but a workaround is to mimic it using a linear gradient.

Answer №2

Is this what you were looking for?

:root{
   --shade: linear-gradient(90deg, rgba(2,0,36,1) 50%, rgba(0,212,255,1) 100%);
}
#text::before{
  content:"";
  width:100%;
  height:18px;
  position:absolute;
  background: var(--shade);
  z-index:-1;
}
#text{
color:white;
  background-color:rgb(0 0 0 / 24%)
}
<div id="text">This is some Text</div>

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

I recently edited my htaccess file to redirect my webpage, but now I'm facing issues with my CSS, images, and

Here is the htaccess code I am using: RewriteRule ^example1/([A-Za-z-]+)/?$ example2.php?name=$1 [NC] The page is loading, but the CSS and JS are not rendering correctly. Can anyone assist me in resolving this issue? ...

Is there a way to locate button designs similar to Bootstrap's without actually relying on the

Looking to incorporate buttons with a similar style to those from Bootstrap into my web app. Does anyone have CSS styles available to achieve this look without relying on Bootstrap? Additionally, is there a collection of historical Bootstrap styles or te ...

show an interactive table with 2 columns for easy printing

My table is generated dynamically to display the work done by employees within a specific time period. Each work item is listed as a new row with 4 columns containing information on time spent, costs, etc. The data looks like this: Worker1 mailservice | ...

Hide the menu even if the user clicks outside of it or anywhere on the webpage

I have a menubar code that is functioning correctly. However, I would like to make an enhancement. Currently, when I click outside of the menubar, it does not hide or close. I want the menubar to be hidden when I click anywhere on the webpage while the men ...

Prevent Android WebView from attempting to fetch or capture resources such as CSS when using loadData() method

Context To many, this situation might appear to be repetitive. However, I assure you that it is not. My objective is to import html data into a WebView, while being able to intercept user hyperlink requests. During this process, I came across this helpfu ...

Transitioning with CSS Scale may result in uneven edges

My current struggle lies with a preloader I designed. It features a simple mask effect that appears as follows: (function() { 'use strict'; setTimeout(function() { document.body.className = 'loaded'; }, 3000); })(); #loade ...

Is using the img-responsive class in Twitter Bootstrap 3 causing my container-fluid divs to resize?

Seeking some insights on a Bootstrap issue I'm experiencing. I've observed that the "container-fluid" divs with responsive images are slightly smaller than those containing only text. This inconsistency in sizing is affecting the overall look o ...

Modify the colors of multiple texts using a concise code block of fewer than 20 lines

I have 8 paragraphs and I want to toggle the class 'one-active' when clicking on each of them, while removing the active class from the others. I currently have the code working for two paragraphs, but it's too lengthy for all eight. How can ...

What is the best way to update the video source upon clicking a link with JQuery?

Is there a way to change the video src using jQuery when a link is clicked? For example, if the user clicks on "#staff", the video src will be updated. <ul class="nav nav-pills" > <li role="presentation" class="loginPills"><a ...

The content is not adapting properly for mobile devices (Bootstrap)

Currently, I am in the midst of a project and require assistance in ensuring an element on my webpage is responsive. Specifically, I need the text within a box to overlap the accompanying image when the browser window is resized. Should I add a class to th ...

The margin of a single flexbox item is not aligned properly

The flexbox I have contains several items. All of them are displaying correctly except for the last one, which is expanding to the edge of the div. View the current appearance of the flexbox As shown in the image, the last element is extending to the con ...

Can someone explain the method for displaying or concealing a menu based on scrolling direction?

https://i.stack.imgur.com/tpDx0.jpg I want to hide this menu when scrolling down and show it when scrolling up. The code for my menu bot is: <script> var previousScroll = 0; $(window).scroll(function(event){ v ...

What is the method used to calculate the heights of flex items when the flex-direction property is set to column?

I'm currently grappling with the concept of flexbox layout and have been exploring the flex-direction: column option. HTML <div class="container"> <div class="item"> Lorem ipsum dolor sit amet consectetur a ...

The font styles shift and vertical bars vanish when placed under images

I'm currently facing some challenges with the text placement beneath the images on my website that I am constructing: 1) The font for "Back to home page" unexpectedly changes from the specified style (Georgia, 0.9em) in Firefox but remains consistent ...

Adding Custom Style to AngularJS Directive using External CSS File

I am attempting to apply a unique style to an angularjs directive using a separate CSS file. .index-nav-bar-directive{ ul{ list-style: none; margin: 0; padding: 0; } h1{ background-color: #2980b9; colo ...

The elegant-admin template's mobile navigation toggle is missing

I recently downloaded an admin theme and added the CSS to my Django static files. However, after doing so, the mobile toggle feature disappeared. I double-checked all the CSS and JS links in the index template, and they are correctly linked to the paths, b ...

Utilize Javascript to conceal images

On a regular basis, I utilize these flashcards. Recently, I have started using images as answers. However, I am facing an issue - I am unable to conceal the pictures. My preference is for the images to be hidden when the webpage loads. function myShowTe ...

Adjust the dimensions of a div using hidden ghost content as the basis

Is there a way to size a <div> element based on ghost content instead of the actual visible content? For example, can we make the box with content "A" appear as if it contains "BCD"? .container { display: flex; width: 10em; } .item { flex-grow: 1; ...

Navigating through the webpage using CSS gradient backdrop

Check out this page. Under the "Pedidos" section, there is a scrolling area with a gradient background. The issue I'm facing is that I want the background to continue scrolling and repeating as I scroll down the page, but it remains fixed. I tried the ...

Conceal or eliminate step titles within the angular-archwizard step

Currently, I am working with angular-archwizard and facing an issue. In the image attached (PFA: image), I do not want the stepTitles to be highlighted or displayed at all. I have attempted to pass a blank string in the "stepTitle" field but unfortunately, ...