2

I'm trying apply module.css to one of my components according to this guide https://nextjs.org/learn/basics/assets-metadata-css/layout-component.

/*/components/Livestream/App.js*/

import styles from './App.module.css';
...
return (
<div className={styles.container}>
 <main>
    <div className='live-stream'>
...
export default App;

/*/components/Livestream/App.module.css*/

.container main {
  align-items: center;
  display: flex;
  height: 100vh;
  justify-content: center;
}

.container main .live-stream {
  background-color: #000615;
  display: flex;
  height: 100%;
  overflow: hidden;
  position: relative;
  width: 100%;
}

However only the main tag gets the css styling and not the class live-stream:

OnlyMainCSS

NotLiveStreamClass

2
  • Ok I just tried it myself. I think that you cannot do it this way, looks like the module.css doesn't recognize or cannot override a external css (? I'm writting this because module.css has only a local scope so...) Maybe you should give your .live-stream a class inside your css module Commented May 12, 2022 at 17:33
  • But the only place on the whole project that a css references .live-stream is on App.module.css, I also tried chaging the main element to a div with class 'main' and the changes were not picked up anymore. Its like main tag works but not class names. Commented May 12, 2022 at 17:50

1 Answer 1

1

Solved like :

<div className={styles.container}>
  <main>
    <div className={styles.liveStream}>

 #CSS
.container main .liveStream {
 // styles
 }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.