2

1 div rounded corners △ with only 5 CSS declarations (no JS, no images other th...

 2 years ago
source link: https://codepen.io/thebabydino/pen/NWXbYwO
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
0 unsaved changes
xxxxxxxxxx
<div></div>

CSS (SCSS)

CSS (SCSS)

@use 'sass:math';
$va: 180deg/3;
$ha: .5*$va;
$sin: math.sin($ha);
$cos: math.cos($ha);
$rc: 20em;
$ri: $rc*$sin;
$h: $rc + $ri;
$bw: .1875*$rc;
$dy: $bw/$sin;
$dv: $dy*$cos;
$sy0: $dv*$cos;
$hl: $rc*$cos;
$vx1: $rc - $hl;
$vx2: $rc + $hl;
$sy1: $dv*$cos;
div {
  display: inline-block;
  padding: $rc;

JS (Babel)

JS (Babel)

xxxxxxxxxx
/*
No JS needed for the actual triangle demo.
External resources only for addding the "watch me code this" link.
*/
999px

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK