html
html
1
2
3
4
5
6
7
8
9
10
11
12
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<div class="heart"></div>
<div class="heart red"></div>
<div class="heart green"></div>
<div class="heart blue"></div>
</body>
</html>
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
:root {
/* change the heart shape from here, or use js to change it, please refer to the next JS pane, sample code there. */
--heart: 100px;
/* coded by Calvin */
}
* {
box-sizing: border-box;
}
.heart {
color: hotpink; /* default color */
width: calc(var(--heart));
height: calc(var(--heart));
background-color: currentcolor;
transform-origin: 50% 50%;
transform: rotate(45deg) translate(calc(var(--heart)/2), 0px);
margin-bottom: calc(var(--heart)/2);
margin-right: calc(var(--heart)/4*3);
display: inline-block;
}
.heart:before,
.heart:after {
content: "";
width: calc(var(--heart));
height: calc(var(--heart));
background-color: currentcolor;
Enter to Rename, Shift+Enter to Preview
js
js
1
2
3
4
5
6
7
8
9
/*
onload = init;
function init() {
var heartSize = 10;
document.documentElement.style.setProperty('--heart', heartSize + 'px');
}
*/
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run