-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a983e1d
commit 7b96563
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.hair { | ||
border-style: solid; | ||
border-width: 1px; | ||
border-color: transparent transparent #999 transparent; | ||
border-radius: 0 0 0 50%/50%; | ||
position: fixed; | ||
background: transparent; | ||
z-index: 100; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
$(function() { | ||
// One in 10 chance of a hair appearing on the page | ||
if (Math.random() < 0.1) { | ||
$("body").append($(` | ||
<div class="hair"></div> | ||
`)); | ||
|
||
// Randomly position the hair | ||
const width = Math.random() * 8 + 2; | ||
const height = Math.random() * 6 + 2; | ||
const top = Math.min(Math.random() * 100, 80 - height); | ||
const left = Math.min(Math.random() * 100, 80 - width); | ||
const angle = Math.random() * 360; | ||
$(".hair").css({ | ||
width: `${width}vw`, | ||
height: `${height}vh`, | ||
top: `${top}vh`, | ||
left: `${left}vw`, | ||
transform: `rotate(${angle}deg)`, | ||
}); | ||
} | ||
}); |