Design comparison
Solution retrospective
- Using CSS, is there an easy way to add a circular border to an element whose box is not square? For this project, I carefully tweaked padding to turn rectangular elements into square elements before applying
border-radius: 100%;
. But, I kept thinking that there must be an easier way.
Community feedback
- @VCaramesPosted almost 2 years ago
Hey there! 👋 Here are some suggestions to help improve your code:
- This LINK is a heading ⚠️ so it needs to wrapped in a
heading
element.
- The “icons/illustrations” in this component are purely decorative. ⚠️ Their
alt tag
should be left blank to hide them from assistive technology.
More Info:📚
https://www.w3.org/WAI/tutorials/images/
- Unfortunately, the HTML for the ratings needs to be rewritten as it was done incorrect ❌:
To ensure that the "rating buttons" are fully accessible 💯, they need to be built using a
form
⚠️.- Everything will be wrapped inside a
fieldset
which will have alegend
that is visually hidden using CSS. - Inside, there should be five
input radios
and eachinput
should have alabel
attached to it to make the “ratings” accessible. - The last thing you will want to include will be a
button
so users can submit their choice.
Here is how it looks like fully implemented: EXAMPLE
More Info: 📚
If you have any questions or need further clarification, you can always check out my submission and/or feel free to reach out to me.
Happy Coding! 👾
Marked as helpful1@harnettdPosted almost 2 years ago@vcarames
Thanks for the detailed feedback. Now that you mention it, it seems that I did indeed use javascript to re-invent the wheel and make radio buttons. I'll re-do that portion of the html and use radio buttons within a form instead.
0 - This LINK is a heading ⚠️ so it needs to wrapped in a
- @sandro21-glitchPosted almost 2 years ago
Hi Derek👋
Yes, you can add a circular border to an element with an irregular shape by using the "clipping" technique.
To do this, you would create a parent element with a circular shape and set its overflow property to "hidden".
Then, you would place the element with the irregular shape inside the parent element, so that only the part of the element within the circular boundary is visible.
Here's an example:
.parent { width: 200px; height: 200px; border-radius: 50%; overflow: hidden; }
.child { width: 300px; height: 100px; }
<div class="parent">
`<div class="child">`This element has a circular border!`</div>`
</div>
In this example, the parent element creates a circular shape, and the child element is clipped so that only the part of it within the circular boundary is visible.
Good Luck
Marked as helpful1@BernardusPHPosted almost 2 years ago@sandro21-glitch If you add a
display: flex; justify-content: center; align-items: center;
on both the parent and child then whatever is in the child, like your example, would be centered in the circle.
Or is there a better way to center it?
Marked as helpful1@sandro21-glitchPosted almost 2 years ago@BernardusPH
Yes, using display: flex with justify-content: center and align-items: center is a common way to center elements both horizontally and vertically within a parent container.
However, there are alternative methods to achieve the same result, such as using display: grid or using CSS margins in combination with absolute positioning. The best approach depends on the specific requirements and context of your design
2@harnettdPosted almost 2 years ago@sandro21-glitch
Thanks for the suggestion of using
overflow: hidden
to put a circle around an element that's not necessarily square. I'll use this technique in my revisions.0@harnettdPosted almost 2 years ago@BernardusPH
Yes, this sounds right. I'll incorporate this into my revisions as well. Thanks.
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