Created
December 11, 2014 13:56
-
-
Save luiz/3f0deb2885c9c1480976 to your computer and use it in GitHub Desktop.
CSS text balloon using variables, calc and transform
This file contains hidden or 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
/* CSS text balloon using variables, calc and transform */ | |
@import url(http://fonts.googleapis.com/css?family=Chewy); | |
div { | |
--balloon-color: #FFF; | |
--balloon-border: 3px; | |
position: relative; | |
top: 1em; | |
left: 1em; | |
display: inline-block; | |
background-color: var(--balloon-color); | |
box-sizing: border-box; | |
padding: 1.2em 2.5ch; | |
text-align: center; | |
font-family: "Chewy", cursive; | |
font-size: 120%; | |
color: #000; | |
border: var(--balloon-border) solid; | |
border-radius: 10px; | |
} | |
div::after { | |
content: ''; | |
position: absolute; | |
top: 100%; | |
left: 70%; | |
--tip-size: 20px; | |
width: var(--tip-size); | |
height: var(--tip-size); | |
background: var(--balloon-color); | |
transform: rotate(45deg) translateY(calc(var(--tip-size) * -0.707)); | |
border-bottom: var(--balloon-border) solid; | |
border-right: var(--balloon-border) solid; | |
} |
This file contains hidden or 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
<div>Oi! Tudo bem?</div> |
This file contains hidden or 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
// alert('Hello world!'); |
This file contains hidden or 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
{"view":"split-vertical","fontsize":"100","seethrough":"","prefixfree":"1","page":"all"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment