Encountering difficulties when trying to showcase a background image using linear-gradient through css modules in the latest version of Next.js

I am experiencing an issue where the CSS code is not displaying the background image properly.

.header {
  height: 85vh;
  background-image: linear-gradient(
      to right bottom,
      rgba(var(--color-primary-light), 0.8),
      rgba(var(--color-primary-dark), 0.8)
    ),
    url('/img/hero-small.jpg');
  background-size: cover;
  background-position: top;
  position: relative;
}

Interestingly, when I remove the linear-gradient property, the background image displays correctly:

.header {
  height: 85vh;
  background-image: url('/img/hero-small.jpg');
  background-size: cover;
  background-position: top;
  position: relative;
}
import styles from '@/app/_components/header.module.css';


const Header = ({children}) => {
  return <header className={styles.header}>{children}</header>;
};

export default Header;

Answer №1

It seems like the issue might stem from a slight error in the syntax.
Instead of using to right bottom, try using to bottom right.

This rule also applies to cardinal directions - we say northwest, not westnorth.

Answer №2

Upon further investigation, I discovered that the root cause of the issue was the fact that my variables were storing values in hexadecimal format while linear-gradient required RGB values. Unlike SASS, CSS does not automatically convert hex values to RGB.

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

Unable to locate the Bootstrap CSS file when deploying on PythonAnywhere

I recently created an admin panel that integrates with a database. To automate the process of generating the admin panel, I utilized flask-admin. Running the server locally on my PC displayed the bootstrap swatch correctly and everything worked seamlessly. ...

Personalizing the presentation of asp.net webforms code

Having recently entered the asp.net realm, I've been intrigued by the talk surrounding asp.net mvc and its superior ability to customize markup and css compared to webforms. Despite hearing that asp.net is easier to learn than asp.net mvc, I've o ...

Is Bootstrap CSS cached by Chrome?

As I began a new project, I decided to tweak the color settings in bootstrap. During debugging in Visual Studio, everything appeared as intended. However, after publishing the site for the first time on a server, I noticed that the color change I made in ...

Finding an Element by its Class Name

Can someone assist me in selecting an element using its class name? I currently have GWT 2.0 and I am trying to accomplish this. Your help would be greatly appreciated. Thank you ...

Tips on incorporating the $ symbol into a pseudo element

Can I add a price using a pseudo element? h3:after{ content: " (+ $75)"; } <h3>price</h3> The CSS minifier is preventing the display of "$75". How can I work around this issue? ...

Collect data from website submissions via email

Is it possible to receive the results via email when someone submits their details on my site using a script? My server does not allow .php or .asp files, only .css. How can I achieve this? ...

Receiving JSON information from a web address using Javascript

I'm currently faced with a challenge in extracting JSON data from a web server. Despite the absence of errors in my code, I encounter difficulties displaying any output. Below is a snippet of the issue: <!DOCTYPE HTML> <html> <head ...

What is the best way to achieve this particular grid layout using html and css?

I have a CSS grid of icons and I am trying to create a divider between each cell that fades in opacity towards the edges, similar to an airbrush effect. However, I want the cells themselves to remain transparent so that the background pattern is still visi ...

Showcasing MySQL Data With Divs

Is it possible to display images from a MySQL database, specifically two images in a row, using div tags instead of tables? I've searched through various articles on Stack Overflow which all suggest using the table tag. However, I am curious if there ...

Steps for eliminating the thick border around <thead> and <tfoot> elements in Bootstrap

Is there a way to remove the thick border on the <thead> and <tfoot> elements in Bootstrap 4 that seems a bit unnecessary? I found a forum post addressing this issue for Bootstrap 5, but unfortunately, the fix didn't work for me since I a ...

Positioning elements precisely on a webpage through absolute positioning and floating them

This seems to present a conflicting situation. Ideally, I am looking to position two child elements on the left and right edges of the parent element, vertically centered, and overlaying all other sibling elements. ...

Is there a way to display the message "no results" when none of the div elements are visible?

I am facing an issue with displaying a message on my webpage. I have multiple divs that are being filtered using filters on a webshop. My goal is to show the message "no results" when all divs have their display set to none. Can anyone provide guidance on ...

Retrieving data from the database using getStaticProps in Next.js

As I was following a tutorial on Next.js, the instructor did something that deviated from what I had learned in school and left me pondering. Here is what he did: interface FaqProps { faq: FaqModel[]; } export default function Faq({ faq }: FaqProps) { ...

Struggling to effectively use XPath to target LI elements that contain specific text

Below is the HTML code for the list item in question: <li class="disabled-result" data-option-array-index="1" style="">4" (0)</li> Here is my attempt at using JavaScript to hide this list item, but it's not working as expected: var xpat ...

Creating extensive pianoroll visualization using HTML and JavaScript

Currently, I am focusing on developing an HTML5 audio application utilizing the latest Web Audio API, and I require a "pianoroll" feature. This is essentially a keyboard grid where users can draw notes, similar to what is seen in many music production soft ...

Steps for dynamically loading mui icons from mui with TypeScript

Is it possible to dynamically load MUI icons based on a string parameter using the following code snippet? import Icon from "@mui/icons-material" import SvgIcon from '@mui/material/SvgIcon'; const IconComponent = (props: typeof SvgIco ...

Utilizing window.location.pathname in Next.js for precise targeting

Are you familiar with targeting window.location.pathname in NEXT.JS? I encountered a red error while using this code in Next.js const path = window.location.pathname console.log(path) // I am able to retrieve the pathname here Then { ...

Exploring the versatility of Next.js: Organizing files for dynamic routing with multiple parameters

Looking to develop dynamic pages with nextjs following the route users/[user]/[dashboard]. My current file structure is set up as follows: pages/ users/ -[user].js // matches for /users/123 - index.js // matches for /users dashboard/ ...

Challenges encountered when setting up a containerized application using Next.js, Flask, and PostgreSQL

Challenge: I've been encountering difficulties in containerizing my application that includes a Next.js frontend, Flask backend, and PostgreSQL database. The primary issue I'm facing currently is the incorrect loading of my PostgreSQL schema. St ...

Smoothly fading div vanishes

I am working on implementing a fade in fade out carousel and here is the code that I have: HTML <div class="flash-container"> <div class="documentsItem"> <a href="" id="lnkDocuments"> <div class="itemtitle" id="divTitle"& ...