Image Not Working

The image is not working, even tho the path is correct.
No description
144 Replies
admin.o7
admin.o7OP9mo ago
App.tsx
No description
admin.o7
admin.o7OP9mo ago
GlassWindow.tsx
No description
ἔρως
ἔρως9mo ago
where can we see this running?
admin.o7
admin.o7OP9mo ago
do you want a pen?
ἔρως
ἔρως9mo ago
or something
Jochem
Jochem9mo ago
Are you getting a 404?
admin.o7
admin.o7OP9mo ago
ἔρως
ἔρως9mo ago
that'll never work on codepen unless you upload the files https://blog.codepen.io/documentation/asset-hosting/
admin.o7
admin.o7OP9mo ago
yeah i forgot let me just upload it by url
ἔρως
ἔρως9mo ago
can you access the file manually, from the browser?
admin.o7
admin.o7OP9mo ago
yes it's on the public folder i have updated the pen
ἔρως
ἔρως9mo ago
you're not going to make it work with unsplashed https://unsplash.com/photos/white-mattress-beside-sectional-sofa-emqnSQwQQDo <-- this is just an html document
Jochem
Jochem9mo ago
you can, but you need to link the actual PNG also, your demo div has zero height
ἔρως
ἔρως9mo ago
it's a temporary file
Mannix
Mannix9mo ago
does your div has any content?
Jochem
Jochem9mo ago
ah
ἔρως
ἔρως9mo ago
and the body had 0 height
Jochem
Jochem9mo ago
picsum.photos then 🙂
ἔρως
ἔρως9mo ago
yup, or placekitty or placehold.it
Mannix
Mannix9mo ago
you either need content in that div or give it a height
ἔρως
ἔρως9mo ago
that wont work
Jochem
Jochem9mo ago
still lamenting the death of fillmurray.com
ἔρως
ἔρως9mo ago
No description
ἔρως
ἔρως9mo ago
oh, wait how the hell is it working with height 0?
admin.o7
admin.o7OP9mo ago
i don't know
Mannix
Mannix9mo ago
the content gives the height the ttttt
admin.o7
admin.o7OP9mo ago
even with height 100% it wont work
Mannix
Mannix9mo ago
100% of 0 is 0
ἔρως
ἔρως9mo ago
No description
ἔρως
ἔρως9mo ago
🤔 it's working
Mannix
Mannix9mo ago
you need to use actual unit
admin.o7
admin.o7OP9mo ago
how
ἔρως
ἔρως9mo ago
i just added content
Mannix
Mannix9mo ago
or html,body{height: 100%;} .bg-image{height: 100%;}
Jochem
Jochem9mo ago
divs don't have an intrinsic height, and background images don't change the height of their element
ἔρως
ἔρως9mo ago
i would use a min-height: 100dvh
admin.o7
admin.o7OP9mo ago
thats what i did?
Jochem
Jochem9mo ago
your empty div collapses to zero pixels high, so you can't see the background image at all
Mannix
Mannix9mo ago
you have height: 0 in your pen
admin.o7
admin.o7OP9mo ago
so what tag should i use
Jochem
Jochem9mo ago
if you're just displaying an image? <img>
admin.o7
admin.o7OP9mo ago
in my react app it's set to 0 by default
ἔρως
ἔρως9mo ago
what are you trying to do?
admin.o7
admin.o7OP9mo ago
i don't want to use img tag
Mannix
Mannix9mo ago
give your bg-image class height with unit any other then %
Jochem
Jochem9mo ago
why?
admin.o7
admin.o7OP9mo ago
wait
ἔρως
ἔρως9mo ago
like, what exactly are you trying to do?
admin.o7
admin.o7OP9mo ago
it worke d
Jochem
Jochem9mo ago
if all you want is to display an image, you have to have a good reason not to just use img or picture
admin.o7
admin.o7OP9mo ago
it was body but i don't want the image on the body
ἔρως
ἔρως9mo ago
dude, what are you trying to do? what do you intend to do? what is the final goal?
admin.o7
admin.o7OP9mo ago
Clueless Expert
YouTube
GLASS Effect With CSS
A Tutorial on how to add a glass effect to a div with CSS With this you can create your own variations, just change the CSS properties the way you like it 📋 CODE ⬇️ .glass{ background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0)); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); b...
admin.o7
admin.o7OP9mo ago
in the video he set the background stuff to the body but i dont want the background to be on a body
ἔρως
ἔρως9mo ago
it doesn't have to be the body
Jochem
Jochem9mo ago
just make sure your div has a height that's 100% of the problem
ἔρως
ἔρως9mo ago
it can be a <div> with height
admin.o7
admin.o7OP9mo ago
doesn't work
No description
ἔρως
ἔρως9mo ago
i would use min-height: 100dvh; with a min-height: 100vh; fallback;
No description
ἔρως
ἔρως9mo ago
100% of 0 is 0
Jochem
Jochem9mo ago
to expand on what epic said, the 100% in this makes the div be 100% the height of its parent, which you've set to 0 in the html, body rule
Jochem
Jochem9mo ago
just for shits and giggles, set it to height: 300px;
admin.o7
admin.o7OP9mo ago
No description
admin.o7
admin.o7OP9mo ago
this is my current code
ἔρως
ἔρως9mo ago
that's still 100% of 0 just try this
admin.o7
admin.o7OP9mo ago
on the html, body?
ἔρως
ἔρως9mo ago
div
Jochem
Jochem9mo ago
in this case, because there is no content (background images don't count) the intrinsic height of html and body are zero
ἔρως
ἔρως9mo ago
^ yup no content = no height = 0
admin.o7
admin.o7OP9mo ago
ok wait ive set to height 300px and it showed something but the image doesn't display correctly
ἔρως
ἔρως9mo ago
that's because it's working it is using the defaults
Jochem
Jochem9mo ago
it's being rendered at 1 to 1 scale, it's not stretching to fit the div by default
ἔρως
ἔρως9mo ago
and it's repeating
Jochem
Jochem9mo ago
you're seeing the full width of the image, but only the top 300px this too
admin.o7
admin.o7OP9mo ago
How I want it to be
No description
ἔρως
ἔρως9mo ago
these are the default values
No description
admin.o7
admin.o7OP9mo ago
how it's displaying
No description
ἔρως
ἔρως9mo ago
it's displaying correctly but it isn't doing what you want do what i said here then it will show at it's full height
admin.o7
admin.o7OP9mo ago
No description
ἔρως
ἔρως9mo ago
there you go now, you need to center the image
Jochem
Jochem9mo ago
now add background-size: cover; to the div
ἔρως
ἔρως9mo ago
and a backgorund-position: center
admin.o7
admin.o7OP9mo ago
already done it didn't do nothing
ἔρως
ἔρως9mo ago
it should
Jochem
Jochem9mo ago
where did you set it?
admin.o7
admin.o7OP9mo ago
bg-image
admin.o7
admin.o7OP9mo ago
No description
ἔρως
ἔρως9mo ago
the order is wrong you're overritting everything with the background
admin.o7
admin.o7OP9mo ago
does that count?
ἔρως
ἔρως9mo ago
YES
Jochem
Jochem9mo ago
yeah, either put background: at the start, or use background-image
ἔρως
ἔρως9mo ago
background-image
admin.o7
admin.o7OP9mo ago
my sanity is just getting away
ἔρως
ἔρως9mo ago
well, you're jumping head-first into the deepend of the cesspool of css weirdness
admin.o7
admin.o7OP9mo ago
WORKED WORKED WORKED thank you guys
Jochem
Jochem9mo ago
that's what the C in CSS means, Cascading. Things lower down in a sheet override things higher up, and because background: is a shorthand, it's unsetting anything background related that isn't defined in the background: property
admin.o7
admin.o7OP9mo ago
doesn't work on zoom btw
ἔρως
ἔρως9mo ago
define "zoom"
admin.o7
admin.o7OP9mo ago
CTRL + mouse wheel
Jochem
Jochem9mo ago
define "not work"
admin.o7
admin.o7OP9mo ago
it doesn't zoom
Jochem
Jochem9mo ago
it's going to stay at the viewport size, because of the vh/dvh and 100% values
ἔρως
ἔρως9mo ago
it keeps the size it was displayed at, because of the background-size: cover;
Jochem
Jochem9mo ago
(for asking questions btw, "doesn't work" is supremely unhelpful. "it doesn't work" just means it's not doing what you expected it to do, but we don't know what you expect it to do)
ἔρως
ἔρως9mo ago
the background image is doing the right thing, even if it seems wrong or doesn't meet your expectations
admin.o7
admin.o7OP9mo ago
now good luck to me, because i have to display elements on top of the image
ἔρως
ἔρως9mo ago
just put stuff inside the div it's a background it's on the back so, everything goes on top you just have to add content to the div
admin.o7
admin.o7OP9mo ago
No description
admin.o7
admin.o7OP9mo ago
let me guess i have to play with position absolute and relative
Jochem
Jochem9mo ago
to do what?
admin.o7
admin.o7OP9mo ago
to display other components on top of the image
Jochem
Jochem9mo ago
no, put the content inside the div
admin.o7
admin.o7OP9mo ago
Worked! I just have to do some tweaking with react children
Jochem
Jochem9mo ago
I'm going to be a bit brutally honest here if I'm honest... If you're struggling with this, it's not yet time for you to be learning React You need to know the basics of HTML, CSS, and JavaScript before you start using frameworks
admin.o7
admin.o7OP9mo ago
i know javascript and typescript i just have to learn CSS which is the most difficult part
Jochem
Jochem9mo ago
but clearly not HTML or CSS, which are just as important
ἔρως
ἔρως9mo ago
no
No description
Jochem
Jochem9mo ago
I'd strongly recommend against trying to learn both by writing React
ἔρως
ἔρως9mo ago
wrong screenshot, sorry
No description
ἔρως
ἔρως9mo ago
yup, learn them by themselves, so you aren't mixing lack of knowledge with lack of knowledge
admin.o7
admin.o7OP9mo ago
so i have a Background component and it will be my actual main component? since i put every other component inside?
ἔρως
ἔρως9mo ago
i don't use react
Jochem
Jochem9mo ago
if you're putting everything inside, why not just put it on the body?
admin.o7
admin.o7OP9mo ago
body just sucks
Jochem
Jochem9mo ago
why?
admin.o7
admin.o7OP9mo ago
you dont want to know
ἔρως
ἔρως9mo ago
react stuff - everything has to be a component?
admin.o7
admin.o7OP9mo ago
if you find out why i hate it then yall prob ban me
Jochem
Jochem9mo ago
unless you hate it for racist or homophobic reasons, that's unlikely
admin.o7
admin.o7OP9mo ago
no thats for another reason it ends with y and it irritates me (you are NOT allowed to react with the skull emoji)
Jochem
Jochem9mo ago
I can appreciate hating things for irrational reasons, but you're going to have to learn to live with the existence of the body tag and you're also going to have to use it if you're going into webdev
admin.o7
admin.o7OP9mo ago
I think I will overcomplicate my life with the div stuff
Jochem
Jochem9mo ago
🤷
admin.o7
admin.o7OP9mo ago
wait if i use body the user doesn't literally care it's only me and my issues with letters irritating me wtf
Jochem
Jochem9mo ago
the user doesn't care how you code your site, as long as it works. Avoiding using body is going to cause you issues though, but if that's what you want to deal with, that's on you. Just remember an employer isn't going to care and isn't going to accept "I don't like it" as a reason for convoluted sollutions to avoid using the body tag
admin.o7
admin.o7OP9mo ago
btw there is another reason i dont want to use the body tag, it doesn't have flexibility?
Jochem
Jochem9mo ago
the body tag does what it needs to do
ἔρως
ἔρως9mo ago
also, doesn't react create a div with id app?
Jochem
Jochem9mo ago
sometimes you can't use it, but sometimes you have to
ἔρως
ἔρως9mo ago
the body tag is a container tag that already exists i understand adding a div, to allow for reducing the width of the size on 24:10 displays but using the div tag as a body tag, as many do, is just unreasonable
admin.o7
admin.o7OP9mo ago
is there a video explaining css to 5 year old
Jochem
Jochem9mo ago
Kevin has a bunch of beginner videos on his channel
Want results from more Discord servers?
Add your server