FAQ Challenge (SVG Doesn't load when used as Background image)
Design comparison
Solution retrospective
- I find it hard to put a stable size for the container is there a way to better do it.
- I saw people put like min-width and min-height on the body then specifying fixed size on the element container I find it hard to get the purpose of all of this.
- When designing of Mobile I added alot of padding so that the SVG doesn't go out of the body half invisible but that screwed the centering part and the fixed width made the Box SVG half seen is there a solution for this type of problems I tried searching but I got nothing.
- Github Doesn't shows the SVG if it was used as background-image is there a fix for that (please don't say embed it as inline it looks messy).
Community feedback
- @vanzasetiaPosted over 2 years ago
Hi, Saleh! 👋
Regarding the problems that you have.
- I recommend keeping it simple by only having one media query to adjust the
max-width
of the container. So, for mobile you can set the initialmax-width
and then a media query to adjust themax-width
of the container for dektop layout. - I strongly recommend against setting any
width
andmin-width
to thebody
element. It usually cause an overflowing issue if they setmin-width: 100vw
orwidth: 100vw
and setwidth: 100%
is useless because by default thebody
element has already full width.min-height
andmin-width
are not a fixed size, they allow the element to grow however not to shrink until the minimum size is set. Formin-height
, it is usually used to center the card element by making thebody
element as a flex container of the card element (it's possible to do it on this challenge). - Which SVG that you are talking about? The SVG should be either the background image of the card element or an
img
element that lives inside the card element with emptyalt=""
. - The same question as above. However, it's usually because of the file path issue. When working with GitHub page, it's best to always put a dot before the forward slash so only either
./
or../
(don't only use forward slash/
).
Two feedback for this solution
- Use HTML native elements for the accordion,
details
andsummary
tags. The current accordion is not accessible by keyboard and screen readers. Also, in general, there's should not be a click event for non-interactive elements, always use interactive elements (e.g. buttons, ect). - Use
forEach
instead offor
loop. It makes your code easier to read and more modern.
Hope this helps. 😊
Marked as helpful1@SalehAbuhusseinPosted over 2 years ago@vanzasetia Thanks For Your Awesome Tips 🥰 That was helpful I will apply it in my next challenge. 3. The SVG I am talking about is the women SVG I added padding to the top of the body so that the SVG is visible to the user.
It was my first Time Doing Javascript Challenge but what I struggled with was the CSS that's silly 😅
0@vanzasetiaPosted over 2 years ago@Honko-o No problem! 👍
I knew how to make the woman SVG appear as the background image! Currently the file path is
../../images/illustration-woman-online-desktop.svg
while theimages/
folder only at one level above instead of two. So now, you should know the correct file path for it. 😉Marked as helpful1@SalehAbuhusseinPosted over 2 years ago@vanzasetia Thanks For your Answer 🥰🥰 I noticed a lot that was really helpful answer and I fixed the SVG paths problem.
0 - I recommend keeping it simple by only having one media query to adjust the
- @mohammedbahniniPosted over 2 years ago
Hi there , check my solution you might get a little help , even i am not a super star in css , but i hope it helps a little bit . (https://www.frontendmentor.io/solutions/accordion-card-component-SyQxOIwS5)
Marked as helpful1@SalehAbuhusseinPosted over 2 years ago@mohammedbahnini Thank you Bro 🥰 I am gonna check it.
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