Responsive Design Portfolio using CSS grid, flexbox and clamp ()
Design comparison
Solution retrospective
Feedback welcome! Especially regarding:
- Code structure and readability
- Accessibility
- Anything else really
I couldn't get the img or screen width with .getBoundingClientRect()
or any other way.
So the image carousel wont function until I figure it out.
Community feedback
- @miroslavdurinPosted over 2 years ago
I don't know how many times you've tried to read
.getBoundingClientRect()
property, but I've noticed that if you select an image and keep on refreshing, sometimes you get width and height and sometimes you don't. That's because the image is not fully loaded every time that.getBoundingClientRect()
function is called. Solution is to put load event on images, it will run when the image is fully loaded, and then to call.getBoundingClientRect()
function. I tried that for one image only and it worked:const img = document.querySelector(".portfolio__carousel li img"); img.addEventListener("load", e=>{ console.log(e.target.getBoundingClientRect()) })
I hope that helped you a little bit...
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord