Skip to content

Instantly share code, notes, and snippets.

@luiz
Created December 11, 2014 13:56
Show Gist options
  • Save luiz/3f0deb2885c9c1480976 to your computer and use it in GitHub Desktop.
Save luiz/3f0deb2885c9c1480976 to your computer and use it in GitHub Desktop.
CSS text balloon using variables, calc and transform
/* 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;
}
<div>Oi! Tudo bem?</div>
// alert('Hello world!');
{"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