Transparent background image

Hey, is this a semantic/efficient way to create an image that has decreased opacity with text on top? https://codepen.io/deerCabin/pen/vYQqrvV
14 Replies
vince
vince17mo ago
Didn't you already do it in your codepen? Or are you looking for something better?
snxxwyy
snxxwyyOP17mo ago
yeah i was playing around with methods for it and was just wondering if there was anything better or if what i had was the best way
vince
vince17mo ago
The way I do it is about the same but I'm curious too if there are better ways
snxxwyy
snxxwyyOP17mo ago
ah which way do you go about it? yeah most people have the section element have the background image and add the ::before pseudo element as a black box with a decreased opacity on top from what i've seen, i just tried to simplify it. just glad i didn't overcomplicate it and that it's valid 😅
vince
vince17mo ago
Your way is better than the way I've been doing it haha The codepen I sent doesn't work 😅 Oh that's why https://codepen.io/vince1444/pen/bGQPjNN
snxxwyy
snxxwyyOP17mo ago
ahhh it's the way i said 😅 seems like we helped eachother here 👍 always good
vince
vince17mo ago
You want to use my way? 🫣 It's worse than yours More markup and css
snxxwyy
snxxwyyOP17mo ago
i meant we figured out mine was a good solution and it helped you improve yours 😅
vince
vince17mo ago
Ohhh haha
snxxwyy
snxxwyyOP17mo ago
yeahh haha thank you
vince
vince17mo ago
ofc 🙂 👍 thank u too
snxxwyy
snxxwyyOP17mo ago
no worries 👍 whilst we're here @vince, back on the topic of layouts 😅, for centering content exactly in a div, let's say for a full screen hero section, any of the methods from flex box justify content & align items to grid place content are all valid methods right? there's no one better than the other etc?
vince
vince17mo ago
Ya it just depends on the content you want inside the section, flex and grid both work but sometimes one is better than the other Just comes down to experience and using them so I'd say just pick one and maybe the next time you implement something similar, you can try grid and see if it's easier Typically my rule though is that if you want your children to determine their own widths, use flex, but if you want your container to determine children widths, use grid
snxxwyy
snxxwyyOP17mo ago
ah gotcha, thank you 👍
Want results from more Discord servers?
Add your server