FAQ accordion card (CSS-only :0) with box animation on desktop
Design comparison
Solution retrospective
I did the accordion using hidden checkboxes and labels. Any tips on how to improve it? And is it fine to do it like this, or can it mess up SEO?
Community feedback
- @pikapikamartPosted about 3 years ago
Hey, awesome work on this one. Layout in desktop looks really good and that box animation is really cool as well. The mobile layout is great as well, for the responsive state, maybe try to center the content, since at point 1100px going down, the content is on the left, stagnant.
For your question:
- Nope, it is totally fine, it won't affect SEO since the content is still present, try viewing the page source of your site, if all the contents are there, you're good.
Some other suggestions would be:
- Don't use
position: absolute
on themain
element, to be honest, you don't need that on this one, this just makes it harder to maintain, as element using this goes out of the flow and you don't want a large container likemain
to be one. You could remove all the:
left top transform position
property on the
main
element, to make it centered, if that's what you want, you only needmargin: 0 auto
then add some padding to the top and bottom of thebody
tag, so that it won't touch the ceiling and flooring.- For this one, I wouldn't really use
input type="checkbox"
for this one, if I would ignore javascript, I would have usedetails
element. By using this, you don't have to manipulate thearia-expanded
and the content inside it will be totally hidden and will only be visible when thedetails
element is toggled, this means more accessible than just using checkboxes. - Since you are using checkbox, to make it better, add the
visibility: hidden
on theanswer
selector, this makes it totally hidden for all users like what it should be, then when theinput
is selected, you addvisibility: visible
on that selector, to make the element appear. - Also, do not add
display: none
to theinput
element, this makes it not target-able by other users, you can click on thelabel
but if you use keyboard or other assistive tech, you can't really toggle it. Addsr-only
element to thecheckbox
only so that it will still be visible for peripherals but not for screen itself. Then add a visual indicator on it, make like usinginput:checked ~ .faq-question .answer:focus-visible
using this selector, you could target theanswer
selector, then add a indicator on it.
Aside from those, great work on this one again,.
Marked as helpful1@willykleitinhoPosted about 3 years ago@pikamart Hey, Raymart! I really appreciate you taking the time to see my code and making suggestions on it. I'll definitely think and learn more about what you said and make changes to the code in this week or the next. Thank you!!
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