Image Not Working

The image is not working, even tho the path is correct.
No description
144 Replies
admin.o7
admin.o77mo ago
App.tsx
No description
admin.o7
admin.o77mo ago
GlassWindow.tsx
No description
ἔρως
ἔρως7mo ago
where can we see this running?
admin.o7
admin.o77mo ago
do you want a pen?
ἔρως
ἔρως7mo ago
or something
Jochem
Jochem7mo ago
Are you getting a 404?
admin.o7
admin.o77mo ago
ἔρως
ἔρως7mo ago
that'll never work on codepen unless you upload the files https://blog.codepen.io/documentation/asset-hosting/
admin.o7
admin.o77mo ago
yeah i forgot let me just upload it by url
ἔρως
ἔρως7mo ago
can you access the file manually, from the browser?
admin.o7
admin.o77mo ago
yes it's on the public folder i have updated the pen
ἔρως
ἔρως7mo 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
Jochem7mo ago
you can, but you need to link the actual PNG also, your demo div has zero height
ἔρως
ἔρως7mo ago
it's a temporary file
Mannix
Mannix7mo ago
does your div has any content?
Jochem
Jochem7mo ago
ah
ἔρως
ἔρως7mo ago
and the body had 0 height
Jochem
Jochem7mo ago
picsum.photos then 🙂
ἔρως
ἔρως7mo ago
yup, or placekitty or placehold.it
Mannix
Mannix7mo ago
you either need content in that div or give it a height
ἔρως
ἔρως7mo ago
that wont work
Jochem
Jochem7mo ago
still lamenting the death of fillmurray.com
ἔρως
ἔρως7mo ago
No description
ἔρως
ἔρως7mo ago
oh, wait how the hell is it working with height 0?
admin.o7
admin.o77mo ago
i don't know
Mannix
Mannix7mo ago
the content gives the height the ttttt
admin.o7
admin.o77mo ago
even with height 100% it wont work
Mannix
Mannix7mo ago
100% of 0 is 0
ἔρως
ἔρως7mo ago
No description
ἔρως
ἔρως7mo ago
🤔 it's working
Mannix
Mannix7mo ago
you need to use actual unit
admin.o7
admin.o77mo ago
how
ἔρως
ἔρως7mo ago
i just added content
Mannix
Mannix7mo ago
or html,body{height: 100%;} .bg-image{height: 100%;}
Jochem
Jochem7mo ago
divs don't have an intrinsic height, and background images don't change the height of their element
ἔρως
ἔρως7mo ago
i would use a min-height: 100dvh
admin.o7
admin.o77mo ago
thats what i did?
Jochem
Jochem7mo ago
your empty div collapses to zero pixels high, so you can't see the background image at all
Mannix
Mannix7mo ago
you have height: 0 in your pen
admin.o7
admin.o77mo ago
so what tag should i use
Jochem
Jochem7mo ago
if you're just displaying an image? <img>
admin.o7
admin.o77mo ago
in my react app it's set to 0 by default
ἔρως
ἔρως7mo ago
what are you trying to do?
admin.o7
admin.o77mo ago
i don't want to use img tag
Mannix
Mannix7mo ago
give your bg-image class height with unit any other then %
Jochem
Jochem7mo ago
why?
admin.o7
admin.o77mo ago
wait
ἔρως
ἔρως7mo ago
like, what exactly are you trying to do?
admin.o7
admin.o77mo ago
it worke d
Jochem
Jochem7mo 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.o77mo ago
it was body but i don't want the image on the body
ἔρως
ἔρως7mo ago
dude, what are you trying to do? what do you intend to do? what is the final goal?
admin.o7
admin.o77mo 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.o77mo ago
in the video he set the background stuff to the body but i dont want the background to be on a body
ἔρως
ἔρως7mo ago
it doesn't have to be the body
Jochem
Jochem7mo ago
just make sure your div has a height that's 100% of the problem
ἔρως
ἔρως7mo ago
it can be a <div> with height
admin.o7
admin.o77mo ago
doesn't work
No description
ἔρως
ἔρως7mo ago
i would use min-height: 100dvh; with a min-height: 100vh; fallback;
No description
ἔρως
ἔρως7mo ago
100% of 0 is 0
Jochem
Jochem7mo 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
Jochem7mo ago
just for shits and giggles, set it to height: 300px;
admin.o7
admin.o77mo ago
No description
admin.o7
admin.o77mo ago
this is my current code
ἔρως
ἔρως7mo ago
that's still 100% of 0 just try this
admin.o7
admin.o77mo ago
on the html, body?
ἔρως
ἔρως7mo ago
div
Jochem
Jochem7mo ago
in this case, because there is no content (background images don't count) the intrinsic height of html and body are zero
ἔρως
ἔρως7mo ago
^ yup no content = no height = 0
admin.o7
admin.o77mo ago
ok wait ive set to height 300px and it showed something but the image doesn't display correctly
ἔρως
ἔρως7mo ago
that's because it's working it is using the defaults
Jochem
Jochem7mo ago
it's being rendered at 1 to 1 scale, it's not stretching to fit the div by default
ἔρως
ἔρως7mo ago
and it's repeating
Jochem
Jochem7mo ago
you're seeing the full width of the image, but only the top 300px this too
admin.o7
admin.o77mo ago
How I want it to be
No description
ἔρως
ἔρως7mo ago
these are the default values
No description
admin.o7
admin.o77mo ago
how it's displaying
No description
ἔρως
ἔρως7mo 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.o77mo ago
No description
ἔρως
ἔρως7mo ago
there you go now, you need to center the image
Jochem
Jochem7mo ago
now add background-size: cover; to the div
ἔρως
ἔρως7mo ago
and a backgorund-position: center
admin.o7
admin.o77mo ago
already done it didn't do nothing
ἔρως
ἔρως7mo ago
it should
Jochem
Jochem7mo ago
where did you set it?
admin.o7
admin.o77mo ago
bg-image
admin.o7
admin.o77mo ago
No description
ἔρως
ἔρως7mo ago
the order is wrong you're overritting everything with the background
admin.o7
admin.o77mo ago
does that count?
ἔρως
ἔρως7mo ago
YES
Jochem
Jochem7mo ago
yeah, either put background: at the start, or use background-image
ἔρως
ἔρως7mo ago
background-image
admin.o7
admin.o77mo ago
my sanity is just getting away
ἔρως
ἔρως7mo ago
well, you're jumping head-first into the deepend of the cesspool of css weirdness
admin.o7
admin.o77mo ago
WORKED WORKED WORKED thank you guys
Jochem
Jochem7mo 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.o77mo ago
doesn't work on zoom btw
ἔρως
ἔρως7mo ago
define "zoom"
admin.o7
admin.o77mo ago
CTRL + mouse wheel
Jochem
Jochem7mo ago
define "not work"
admin.o7
admin.o77mo ago
it doesn't zoom
Jochem
Jochem7mo ago
it's going to stay at the viewport size, because of the vh/dvh and 100% values
ἔρως
ἔρως7mo ago
it keeps the size it was displayed at, because of the background-size: cover;
Jochem
Jochem7mo 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)
ἔρως
ἔρως7mo ago
the background image is doing the right thing, even if it seems wrong or doesn't meet your expectations
admin.o7
admin.o77mo ago
now good luck to me, because i have to display elements on top of the image
ἔρως
ἔρως7mo 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.o77mo ago
No description
admin.o7
admin.o77mo ago
let me guess i have to play with position absolute and relative
Jochem
Jochem7mo ago
to do what?
admin.o7
admin.o77mo ago
to display other components on top of the image
Jochem
Jochem7mo ago
no, put the content inside the div
admin.o7
admin.o77mo ago
Worked! I just have to do some tweaking with react children
Jochem
Jochem7mo 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.o77mo ago
i know javascript and typescript i just have to learn CSS which is the most difficult part
Jochem
Jochem7mo ago
but clearly not HTML or CSS, which are just as important
ἔρως
ἔρως7mo ago
no
No description
Jochem
Jochem7mo ago
I'd strongly recommend against trying to learn both by writing React
ἔρως
ἔρως7mo ago
wrong screenshot, sorry
No description
ἔρως
ἔρως7mo ago
yup, learn them by themselves, so you aren't mixing lack of knowledge with lack of knowledge
admin.o7
admin.o77mo ago
so i have a Background component and it will be my actual main component? since i put every other component inside?
ἔρως
ἔρως7mo ago
i don't use react
Jochem
Jochem7mo ago
if you're putting everything inside, why not just put it on the body?
admin.o7
admin.o77mo ago
body just sucks
Jochem
Jochem7mo ago
why?
admin.o7
admin.o77mo ago
you dont want to know
ἔρως
ἔρως7mo ago
react stuff - everything has to be a component?
admin.o7
admin.o77mo ago
if you find out why i hate it then yall prob ban me
Jochem
Jochem7mo ago
unless you hate it for racist or homophobic reasons, that's unlikely
admin.o7
admin.o77mo 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
Jochem7mo 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.o77mo ago
I think I will overcomplicate my life with the div stuff
Jochem
Jochem7mo ago
🤷
admin.o7
admin.o77mo 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
Jochem7mo 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.o77mo ago
btw there is another reason i dont want to use the body tag, it doesn't have flexibility?
Jochem
Jochem7mo ago
the body tag does what it needs to do
ἔρως
ἔρως7mo ago
also, doesn't react create a div with id app?
Jochem
Jochem7mo ago
sometimes you can't use it, but sometimes you have to
ἔρως
ἔρως7mo 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.o77mo ago
is there a video explaining css to 5 year old
Jochem
Jochem7mo ago
Kevin has a bunch of beginner videos on his channel
Want results from more Discord servers?
Add your server