I am currently adding a gradient overlay to the background of a bootstrap card, but I am experiencing an issue where the title text is also affected by the overlay

https://i.sstatic.net/Yxn4P.png

Here is how I structured my HTML to include the title as a prop for Bootstrap card. Despite trying z-index, I didn't get the desired outcome.

<b-col>
              <div class="card-container">
                <b-card
                  overlay
                  img-src="/images/ajm.jpg"
                  img-alt="Card Image"
                  class="product-card"
                  title="Linear Motors"
                  title-tag="h5"
                  align="center"
                ></b-card>
              </div>
            </b-col>

CSS ----->

.product-card {
  height: 353px;
  border-radius: 0px;
  border: 0;
  color: #0c1c35;
}

.card-container {
  width: 100%;
  height: 100%;
  :hover {
    background: -webkit-linear-gradient(
      90deg,
      hsla(217, 100%, 50%, 1) 0%,
      hsla(186, 100%, 69%, 1) 100%
    );
    opacity: 0.8;
    color: white;
  }
}

Answer №1

Something else to consider is that the opacity property affects child elements, as explained on w3 schools:

If you don't want the opacity to apply to child elements, like in the example above, use RGBA color values. This code snippet demonstrates setting opacity for the background color only, not the text: 

Based on your CSS code using opacity, switching to RGBA might be a solution worth trying.

.card-container { 
  background-color: rgba(255, 255, 255, 0.5); 
}

I hope this suggestion proves beneficial!

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

What is the best way to make a Modal triggered by a loop embedded within a table function properly on mobile devices?

While the modal is functioning properly on desktop, it seems to be encountering issues on mobile devices. The modal appears behind the background and is confined by the boundaries of the table (tbody). Below is the code snippet for triggering the modal: ...

Optimizing carousel image dimensions for various screen sizes

I'm currently working on a full screen carousel in HTML and I'm curious about the optimal image size to ensure it resizes properly on all screen sizes without any distortion. Can anyone help me out with this? ...

Stop cascading styles when using nested rules in LESS to prevent unintended style application

In the process of developing a sophisticated front-end system using plugins, we are exploring different methods for composing CSS rules. Currently, we are considering two main approaches: Including parents in the class name Nesting parents in the selecto ...

variety of heights in the product grid for an eclectic look

Hey there! I'm currently experimenting with a simple product grid for testing purposes only. It's not a final design, just trying to work out some kinks. One issue I'm facing is with the heights of the elements. When text spans over two line ...

Adding space between the cells on the far left and far right of the table and the border

I need some advice on creating a table in HTML where the borders of the leftmost and right most cells do not extend all the way to the edges of the table. Here's an example: | ____ | In this example, the top border of the cells is continuous within ...

Bootstrap tools

After deciding not to use react bootstrap, I found a helpful blog post that guided me in adding Bootstrap 4.6 to my react app via CDN links. Here's how I updated my template: In the head section, I added: <link rel="stylesheet" href=&quo ...

Display a section of a webpage with the CSS styles hidden

I encountered an issue while attempting to print a section of my website. Despite having CSS information embedded in my HTML file, the properties are not being displayed. Do you have any solutions for this problem? var content = document.getElementById("d ...

`Nav arrow positioning problem in absolute position`

I'm experiencing an issue with the left navigation arrow in a portfolio viewer I'm using. It seems to be moving along with the window size and I can't seem to find a way to keep it contained within my div and stationary. The plugin responsib ...

Could someone please clarify a specific aspect of how floats work?

Could someone simplify this explanation for me? A float is positioned next to a line box if there is a vertical space that meets these conditions: (a) at or below the top of the line box, (b) at or above the bottom of the line box, (c) below the top margi ...

How can I ensure that the position of an image within a button remains fixed as the button's width expands upon hovering?

Whenever I hover over the button, it changes width as intended but the image shifts towards the center. My goal is to keep it fixed on the left so it doesn't shift when the button's width changes. Below is my React code: <div> < ...

Adjust css rotation to direct an element towards a specific point

Looking to rotate a div towards a point using the CSS 3 transform rotate function. Progress so far: View code on JSFiddle $(document).ready(function(){ var scw,sch,scx,scy; calcCenter(); $(window).resize(function() { calcCent ...

mapping buttons to images based on dynamic conditions

In my folder, I have over 1000 files. Using opendir, readdir, and is_dir, I can display the thumbnails of these files in my browser. Each thumbnail also has a corresponding button assigned to it. What I'm looking to do now is delete the 500th image wh ...

Looking to position a dropdown at the right edge using CSS grid?

I am currently in the process of familiarizing myself with css grid. My goal is to align a responsive drop down menu to the right using css grid techniques. I understand that there are numerous approaches to achieve this relatively straightforward task, bu ...

Exchanging text between varying divs and classes

On my webpage, I have multiple boxes of cards where content can dynamically populate. Each box contains a click-to-open accordion feature in the upper right corner. I am struggling to figure out how to change the text of only the clicked box without affect ...

Ways to conceal the TippyJS tooltip so it doesn't show up on video embeds

My website has tooltips enabled, but I am looking to hide the tooltip pop-ups that appear specifically over youtube video embeds. Upon inspecting the webpage, I found the code snippet below that is associated with youtube videos: <div data-tippy-root id ...

Creating a CSS layout that expands a container to fill the entire height of its grandparent element

Currently, I am developing a web application and facing challenges with the layout. The expected design includes 3 significant components: Article Header Article Content Article Footer Utilizing CSS Flexbox makes it relatively simple to implement this ...

Ways to conceal a text-filled div behind an image using 3D transformation

I've been working on creating three images with a fun 'flipcard' effect for the past day and a half, and I believe I'm getting closer to achieving my goal. However, there is one issue remaining, as you can see in the codepen. When the ...

Lost item phenomenon: conceal information below until it emerges

I'm attempting to create a garage door effect on my website, where upon loading the page, a garage door is displayed. Upon hovering over the door, it lifts up to reveal the content behind it. The challenge I'm facing is keeping the content hidden ...

Is it possible to execute a PHP script within a .css file and ensure it functions correctly?

Recently, I've been making some changes to the .css file in order to get my PHP codes to work. However, when I insert them as usual, they appear as regular text. I'm curious to find out if it's possible to execute a PHP file within a .css fi ...

How to change a CSS class when clicking with AngularJS

I want to implement a feature where the CSS class of a div element changes when clicked. The default class should be 'input-large', and on click, it should change to 'input-large input-active'. This change should occur when clicking on ...