HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URL's added here will be added as <link>
s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
If the stylesheet you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
.container
.content
h1 Pure CSS Tooltips
h2 Tooltips on Divs
.row
.col-sm-3.col-xs-6.text-center
.t-top.t-sm.bordered(data-tooltip='Top Tooltip') Div
.col-sm-3.col-xs-6.text-center
.t-right.t-sm.bordered(data-tooltip='Right Tooltip') Div
.col-sm-3.col-xs-6.text-center
.t-bottom.t-md.bordered(data-tooltip='Bottom Tooltip') Div
.col-sm-3.col-xs-6.text-center
.t-left.t-sm.bordered(data-tooltip='Left Tooltip') Div
h2 Tooltips on Buttons
.row
.col-sm-3.col-xs-6.text-center
button.t-top.t-sm.btn.btn-block.btn-success(data-tooltip='Top Tooltip') Button
.col-sm-3.col-xs-6.text-center
button.t-right.t-sm.btn.btn-block.btn-primary(data-tooltip='Right Tooltip') Button
.col-sm-3.col-xs-6.text-center
button.t-bottom.t-md.btn.btn-block.btn-danger(data-tooltip='Bottom Tooltip') Button
.col-sm-3.col-xs-6.text-center
button.t-left.t-sm.btn.btn-block.btn-warning(data-tooltip='Left Tooltip') Button
h2 Tooltips on Inputs
.row
.col-sm-3.col-xs-6.text-center
.t-top.t-sm.full-width(data-tooltip='Top Tooltip')
input.form-control.text-center(placeholder='Input')
.col-sm-3.col-xs-6.text-center
.t-right.t-sm.full-width(data-tooltip='Right Tooltip')
input.form-control.text-center(placeholder='Input')
.col-sm-3.col-xs-6.text-center
.t-bottom.t-md.full-width(data-tooltip='Bottom Tooltip')
input.form-control.text-center(placeholder='Input')
.col-sm-3.col-xs-6.text-center
.t-left.t-sm.full-width(data-tooltip='Left Tooltip')
input.form-control.text-center(placeholder='Input')
h2 Tooltips on Links
p Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi viverra augue quis consequat viverra. Sed pulvinar lacus urna. Nullam sed nisl semper, elementum nisl eu, semper ex. Vestibulum bibendum at neque id dictum. <a href="#" class="t-bottom t-md" data-tooltip="Bottom Tooltip">Maecenas</a> at magna semper, malesuada libero faucibus, eleifend mauris. Nullam dignissim blandit justo, nec dictum risus dapibus at. In hac habitasse platea dictumst. Praesent nec nulla ullamcorper, commodo tellus id, consectetur metus. In euismod augue lectus, vitae pretium tortor auctor suscipit.
p Sed vulputate luctus metus sed varius. Aliquam auctor lobortis ante, nec dignissim sem sodales at. Sed sed dolor ex. Curabitur pharetra, nibh ut aliquam varius, nisl mi vulputate diam, eget scelerisque odio felis sed justo. Suspendisse odio ligula, semper ac dui vitae, hendrerit hendrerit felis. Ut vel rutrum nunc, sit amet euismod turpis. Suspendisse quis nisl consectetur, ullamcorper lacus non, euismod mi. Proin nec justo vel libero semper malesuada pellentesque eget sem. <a href="#" class="t-top t-sm" data-tooltip="Top Tooltip">Quisque</a> et lacus a dolor fermentum vestibulum ut non neque. Vivamus iaculis sodales interdum. Aliquam pretium tempor erat vel posuere. Nam tellus diam, ultricies at sollicitudin ut, hendrerit id quam. In viverra elementum ex nec congue.
@import url('https://fonts.googleapis.com/css?family=Open+Sans:400,700')
@import url('https://fonts.googleapis.com/css?family=Pacifico')
body
background-color: #e0e0e0
font-family: 'Open Sans', sans-serif
font-size: 14px
line-height: 21px
padding: 15px 0
.content
background: #fff
border-radius: 3px
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.075), 0 2px 4px rgba(0, 0, 0, 0.0375)
padding: 30px
h1
color: #333
font-family: 'Pacifico', cursive
font-size: 28px
line-height: 42px
margin: 0 0 15px
text-align: center
h2
border-bottom: 1px solid #ddd
color: #aaa
font-size: 12px
line-height: 24px
margin: 0 0 15px
padding: 0
position: relative
text-align: center
a
color: red !important
font-weight: bold
div[class^="col"]
margin-bottom: 25px
.bordered
background: #e2e2e2
border: 1px solid #ccc
padding: 5px 10px
.full-width
width: 100%
[data-tooltip]
cursor: pointer
position: relative
&:before, &:after
position: absolute
visibility: hidden
opacity: 0
pointer-events: none
transition: all .15s cubic-bezier(.5, 1, .25, 1)
z-index: 1
&:before
padding: 5px
width: 110px
border-radius: 3px
background: #000
color: #fff
content: attr(data-tooltip)
text-align: center
font-size: 14px
font-weight: normal
line-height: 1.2
&:after
border: 8px solid transparent
width: 0
content: ""
font-size: 0
line-height: 0
/********** Default Behavior **********/
&:hover:before, &:hover:after
visibility: visible
opacity: 1
/********** Timeout Variant **********/
//@keyframes timeout
0%
opacity: 1
visibility: visible
99%
opacity: 1
visibility: visible
100%
opacity: 0
visibility: hidden
//&:hover:before, &:hover:after
animation: timeout 2s
/********** Tooltip Sizes **********/
&.t-xl:before
width: 200px
&.t-lg:before
width: 170px
&.t-md:before
width: 140px
&.t-sm:before
width: 110px
&.t-xs:before
width: 80px
/********** Top Tooltip **********/
&.t-top
&:before
bottom: 100%
left: 50%
margin-bottom: 5px
transform: translateX(-50%)
&:after
bottom: 100%
left: 50%
transform: translateX(-50%)
border-top: 8px solid #000
border-bottom: none
&:hover:before, &:hover:after
transform: translateX(-50%) translateY(-5px)
/********** Right Tooltip **********/
&.t-right
&:before
top: 50%
left: 100%
margin-left: 5px
transform: translateY(-50%)
&:after
top: 50%
left: 100%
transform: translateY(-50%)
border-right: 8px solid #000
border-left: none
&:hover:before, &:hover:after
transform: translateX(5px) translateY(-50%)
/********** Bottom Tooltip **********/
&.t-bottom
&:before
top: 100%
left: 50%
margin-top: 5px
transform: translateX(-50%)
&:after
top: 100%
left: 50%
transform: translateX(-50%)
border-bottom: 8px solid #000
border-top: none
&:hover:before, &:hover:after
transform: translateX(-50%) translateY(5px)
/********** Left Tooltip **********/
&.t-left
&:before
top: 50%
right: 100%
margin-right: 5px
transform: translateY(-50%)
&:after
top: 50%
right: 100%
transform: translateY(-50%)
border-left: 8px solid #000
border-right: none
&:hover:before, &:hover:after
transform: translateX(-5px) translateY(-50%)
/*
No JS Required
Example HTML:
<div class="t-top t-sm" data-tooltip="XXX">XXX</div>
Simply choose your preferred Content, Alignment, and Size.
Content:
* data-tooltip='XXX'
Alignment:
* Top = t-top
* Right = t-right
* Bottom = t-bottom
* Left = t-left
Size:
* Extra Small = t-xs
* Small = t-sm
* Medium = t-md
* Large = t-lg
* Extra Large = t-xl
*/
Also see: Tab Triggers