0

.c{
    display: flex;
    padding-top: 18em;
    .backgroundDiv{
        background: url("/images/DSC8253.png");
        background-repeat: no-repeat;
        background-size: cover;
        background-position: center center ;
        height: 20em;
        opacity: 0.6;
         position: absolute;
         width: 100%;
         z-index: -1;
         
    }
}
.bigText{
    display: flex;
    text-transform: uppercase;
    font-size: 3em;
    font-family: cursive;
    font-weight: 600;
    height: 8em;
    top:2em;
}
 <section class="c">
         <div class="backgroundDiv"></div>
         <div class="bigText">
             <p>Pilki-HUILKI</p>
             </div>
     </section>
Nathaniel Flick
  • 2,902
  • 2
  • 22
  • 31
  • 1
    Have you tried using rbga() colour for the bg instead of opacity? Opacity will change the opacity of the text as well that's in the div, rbga() will only change the background. – Nathaniel Flick Oct 27 '21 at 19:42
  • @NathanielFlick this would work with a background image? Which property do you mean should be set with an rgba() value? – Corrl Oct 27 '21 at 20:03
  • Are you using a preprocessor because that doesn't look like CSS. However, when I make it CSS the text is over the image OK. Could you describe what you want the outcome to look like? – A Haworth Oct 27 '21 at 20:20
  • rgba will set opacity for colot how it suppose to work with image? i use sass yes. there is a git folder with fuul code atm – DeanWinchester88 Oct 27 '21 at 20:22
  • @Corrl whoops I forgot there's an image there, not a color. – Nathaniel Flick Oct 28 '21 at 01:53

1 Answers1

-1

Here in css file you type like below ( just small change )

.c {
  display: flex;
  position: relative;
  height: 100vh;
}

.backgroundDiv {
  background: url('/images/DSC8253.png');
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center center;
  height: 20em;
  opacity: 0.6;
  position: absolute;
  width: 100%;
  z-index: -1;
}
.bigText {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  text-transform: uppercase;
  font-size: 3em;
  font-family: cursive;
  font-weight: 600;
}

I use position absolute to make the text over the background then i use transform to make it to the center

An in real life
  • 108
  • 2
  • 7