My use case for this CSS is to have a big arrow at the background of a reveal.js slideshow like so. See all the credits in the Credits section, most notably the pen by @LukyVj gave me a head start.
Created
September 5, 2022 21:40
-
-
Save pjastam/cadc89cc7a728e5bec314a212f9fe00b to your computer and use it in GitHub Desktop.
Easy customizable CSS arrow
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<link rel="stylesheet" href="css/my-arrow.css" type="text/css"> | |
</head> | |
<body> | |
<h1>Easy customizable css arrow</h1> | |
<div class="arrow"></div> | |
</body> | |
</html> |
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
/* | |
* Easy customizable CSS arrow: | |
# Change size, position & color w/ global CSS variables | |
* | |
* 2022 @pjastam | |
* http://www.pietstam.nl | |
* | |
* Credits | |
* - CSS arrow: https://codepen.io/LukyVj/pen/AveZjg | |
* - CSS constants: https://stackoverflow.com/a/48175165 | |
* - CSS calc: https://stackoverflow.com/a/53244557 | |
*/ |
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
/* == Default page == */ | |
:root { | |
box-sizing: border-box; | |
text-align: left; | |
font-weight: bold; | |
background-color: LightGray; | |
color: Grey; | |
--custom-top: 150px; | |
--custom-left: 400px; | |
--custom-width: 200px; | |
--custom-height: 100px; | |
--custom-width-triangle: 150px; | |
--custom-color: Tomato; | |
} | |
/* == Style == */ | |
.arrow { | |
position: absolute; | |
top: var(--custom-top); | |
left: var(--custom-left); | |
width: var(--custom-width); | |
height: var(--custom-height); | |
background-color: var(--custom-color); | |
} | |
.arrow::after { | |
position: relative; | |
margin: calc(var(--custom-height) / 2 * -1) calc(var(--custom-width) - 1px); | |
display: block; | |
content: ""; | |
border-top: var(--custom-height) solid transparent; | |
border-bottom: var(--custom-height) solid transparent; | |
border-left: var(--custom-width-triangle) solid var(--custom-color); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment