Conditional Border Radius In CSS

Ahmad Shadeed recently spotted this CSS declaration in the Facebook CSS Source: .card { border-radius: max(0px, min(8px, calc((100vw – 4px – 100%) * 9999))); } It’s a really interesting piece of code, which acts as a toggle to only show rounded corners in case the element is not fullwidth. We don’t want rounded corners when …


This content originally appeared on Bram.us and was authored by Bramus!

Ahmad Shadeed recently spotted this CSS declaration in the Facebook CSS Source:

.card {
   border-radius: max(0px, min(8px, calc((100vw - 4px - 100%) * 9999)));
}

It’s a really interesting piece of code, which acts as a toggle to only show rounded corners in case the element is not fullwidth.

You can see it in action in this (resizable) demo:

See the Pen
Border radius / FB
by Ahmad Shadeed (@shadeed)
on CodePen.

On his blog, Ahmad lays out the details how exactly the math works.

Conditional Border Radius In CSS →


This content originally appeared on Bram.us and was authored by Bramus!


Print Share Comment Cite Upload Translate Updates
APA

Bramus! | Sciencx (2021-10-05T08:58:08+00:00) Conditional Border Radius In CSS. Retrieved from https://www.scien.cx/2021/10/05/conditional-border-radius-in-css-2/

MLA
" » Conditional Border Radius In CSS." Bramus! | Sciencx - Tuesday October 5, 2021, https://www.scien.cx/2021/10/05/conditional-border-radius-in-css-2/
HARVARD
Bramus! | Sciencx Tuesday October 5, 2021 » Conditional Border Radius In CSS., viewed ,<https://www.scien.cx/2021/10/05/conditional-border-radius-in-css-2/>
VANCOUVER
Bramus! | Sciencx - » Conditional Border Radius In CSS. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/10/05/conditional-border-radius-in-css-2/
CHICAGO
" » Conditional Border Radius In CSS." Bramus! | Sciencx - Accessed . https://www.scien.cx/2021/10/05/conditional-border-radius-in-css-2/
IEEE
" » Conditional Border Radius In CSS." Bramus! | Sciencx [Online]. Available: https://www.scien.cx/2021/10/05/conditional-border-radius-in-css-2/. [Accessed: ]
rf:citation
» Conditional Border Radius In CSS | Bramus! | Sciencx | https://www.scien.cx/2021/10/05/conditional-border-radius-in-css-2/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.