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 URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
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.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and 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 esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM 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.
<div class="wrap">
<section class="question-section">
<h1>Pure CSS Content Accordion</h1>
<p>A pure CSS solution to a classically JS driven UI element.</p>
<div class="cat-1">
<input id="tab-1" type="radio" name="tabs" tabindex="1">
<label for="tab-1" >Technical</label><!-- end of tab label -->
<div class="question-wrap">
<div class="question">
<input id="question-1" type="radio" name="questions-tab-one" tabindex="2">
<label for="question-1" >What exactly is a content accordion?</label><!-- end of question label -->
<p class="answer answer-1">A content accordion is a common UI pattern that allows you to provide extra content on demand when a trigger is clicked. The animation is usually a slide down or to the side like an accordion, hence the name.</p>
</div>
<div class="question">
<input id="question-2" type="radio" name="questions-tab-one" tabindex="3">
<label for="question-2" >I don't need JavaScript for this?</label><!-- end of question label -->
<p class="answer answer-2">Using hidden inputs and labels, you can create a Css-only accordion that will animate the content areas.</p>
</div>
<div class="question">
<input id="question-3" type="radio" name="questions-tab-one" tabindex="4">
<label for="question-3" >How hard is it to do?</label><!-- end of question label -->
<p class="answer answer-3">Easy peasy. With the use of child and sibling selectors you can target the content area that is either child or sibling to the input that has been selected.</p>
</div>
<div class="question">
<input id="question-4" type="radio" name="questions-tab-one" tabindex="5">
<label for="question-4" >Can I follow you on twitter?</label><!-- end of question label -->
<p class="answer answer-4">Yup, you sure can. Get cool tips on sass and what nots at <a href="https://twitter.com/Dave_Conner" tabindex="6">@Dave_Conner</a></p>
</div>
</div>
</div><!-- end of Catagory -->
<div class="cat-2">
<input id="tab-2" type="radio" name="tabs" tabindex="7">
<label for="tab-2" >SassBreak</label>
<div class="question-wrap">
<div class="question">
<input id="question-5" type="radio" name="questions-tab-two" tabindex="8">
<label for="question-5" >Poly – A Modular UI Kit Built with Sass</label><!-- end of question label -->
<p class="answer">Poly is a simple, responsive UI toolkit for everyone to share and enjoy! <a href="http://sassbreak.com/poly-ui-toolkit/" tabindex="9">Read More</a></p>
</div>
<div class="question">
<input id="question-6" type="radio" name="questions-tab-two" tabindex="10">
<label for="question-6" >Watch Yo' Sass</label><!-- end of question label -->
<p class="answer">I know the feeling: You just installed Sass, eager to dive into all of its awesome features and finally convert that stale CSS project over to Sass. You create your first .scss file, crack open Terminal, type a --watch command—everything comes to a hault. <a href="http://sassbreak.com/watch-your-sass/" tab-index="11">Read More</a></p>
</div>
<div class="question">
<input id="question-7" type="radio" name="questions-tab-two" tabindex="12">
<label for="question-7" >CSS Blend Modes with Sass</label><!-- end of question label -->
<p class="answer">CSS blend modes are a new feature that let us blend an element’s background layer with another layer. They’re commonly used for blending a background image with a background color. <a href="http://sassbreak.com/css-blend-modes-with-sass/" tab-index="13">Read More</a></p>
</div>
<div class="question">
<input id="question-8" type="radio" name="questions-tab-two" tabindex="14">
<label for="question-8" >Viewport-Relative Headings with Sass</label><!-- end of question label -->
<p class="answer">Viewport-relative units (vw, vh, vmin, vmax) are a new set of dynamic CSS units for sizing elements. They’re called “viewport-relative” because they eliminate dependency on parent elements and allow sizing based on the viewport size. <a href="http://sassbreak.com/viewport-relative-headings-with-sass/" tab-index="15">Read More</a> </p>
</div>
</div>
</div>
<div class="cat-3">
<input id="tab-3" type="radio" name="tabs" tabindex="16">
<label for="tab-3" >Other Pens</label>
<div class="question-wrap">
<div class="question">
<input id="question-9" type="radio" name="questions-tab-three" tabindex="17">
<label for="question-9" >Collection of Button Hover Effects</label><!-- end of question label -->
<p class="answer">A few button hover effects using a couple different methods. SVG and pseudo elements make for some nice pizazz! <a href="https://codepen.io/davidicus/full/emgQKJ/" tabindex="18">Go to pen.</a></p>
</div>
<div class="question">
<input id="question-10" type="radio" name="questions-tab-three" tabindex="19">
<label for="question-10" >Pure CSS Credit Cards</label><!-- end of question label -->
<p class="answer">Mulitple credit cards made entirely with CSS and fully responsive. <a href="https://codepen.io/davidicus/full/LEWReB/" tabindex="20">Go to pen.</a></p>
</div>
<div class="question">
<input id="question-11" type="radio" name="questions-tab-three" tabindex="21">
<label for="question-11" >CSS Rocket and Animation</label><!-- end of question label -->
<p class="answer">Rocket built and animations all using CSS. <a href="https://codepen.io/davidicus/full/dPvQPM/" tabindex="22">Go to pen.</a></p>
</div>
<div class="question">
<input id="question-12" type="radio" name="questions-tab-three" tabindex="23">
<label for="question-12" >Pure CSS Devices and Animation</label><!-- end of question label -->
<p class="answer">Building for the modern web means building for all devices. Use of CSS to both form and morph one device into another. Oldie but goodie. <a href="https://codepen.io/davidicus/full/dDAqC/" tabindex="24">Go to pen.</a></p>
</div>
</div>
</div>
<div class="cat-4">
<input id="tab-4" type="radio" name="tabs" tabindex="25">
<label for="tab-4" >Lorem Ipsum</label>
<div class="question-wrap">
<div class="question">
<input id="question-13" type="radio" name="questions-tab-four" tabindex="26">
<label for="question-13" >Lorem ipsum dolor sit elit?</label><!-- end of question label -->
<p class="answer">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ac laoreet elit. Phasellus dignissim purus vitae urna cursus, quis congue ligula tristique. Ut nec blandit risus. Donec at orci ut justo venenatis viverra.</p>
</div>
<div class="question">
<input id="question-14" type="radio" name="questions-tab-four" tabindex="27">
<label for="question-14" >Nunc vitae ultrices tortor?</label><!-- end of question label -->
<p class="answer">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ac laoreet elit. Phasellus dignissim purus vitae urna cursus, quis congue ligula tristique. Ut nec blandit risus. Donec at orci ut justo venenatis viverra. </p>
</div>
<div class="question">
<input id="question-15" type="radio" name="questions-tab-four" tabindex="28">
<label for="question-15" >Donec metus nibh, condimentum vehicula? </label><!-- end of question label -->
<p class="answer">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ac laoreet elit. Phasellus dignissim purus vitae urna cursus, quis congue ligula tristique. Ut nec blandit risus. Donec at orci ut justo venenatis viverra. </p>
</div>
<div class="question">
<input id="question-16" type="radio" name="questions-tab-four" tabindex="29">
<label for="question-16" >Condimentum nec vehicula?</label><!-- end of question label -->
<p class="answer">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ac laoreet elit. Phasellus dignissim purus vitae urna cursus, quis congue ligula tristique. Ut nec blandit risus. Donec at orci ut justo venenatis viverra. </p>
</div>
</div>
</div>
</section><!-- End of Questions -->
</div>
@import "compass/css3";
@import url(https://fonts.googleapis.com/css?family=Audiowide);
//colors
$blue: #85D8CE;
$blue-dark: #085078;
$blue-light: #D4FAF6;
//mixins
@mixin bp($bp, $min-max: min-width) {
$em: $bp/16;
@media(#{$min-max}: #{$em}em) {
@content;
}
}
//bug fix for general sibling.
body { -webkit-animation: bugfix infinite 1s; }
@-webkit-keyframes bugfix { from { padding: 0; } to { padding: 0; } }
body {
background: radial-gradient(ellipse farthest-side at 100% 100%, $blue-light 1%, $blue 30%, $blue-dark 120%);
background-attachment: fixed;
padding-top: 2em;
overflow-y: scroll;
}
.wrap {
display: block;
max-width: 1024px;
margin: 0 auto 2em;
padding: 0 1em;
width: 100%;
@include bp(700) {
padding: 3em;
}
}
p {
color: #555;
text-shadow: 1px 1px 1px #fff;
}
a, a:visited {
color: darken($blue, 15%);
text-decoration: none;
}
//questions styles
.question-section {
background: lighten($blue-light, 5%);
box-shadow: 0 2px 5px rgba(#444, .4);
display: inline-block;
font-size: 1rem;
margin-bottom: 1em;
padding: 1em;
position: relative;
vertical-align: top;
width: 100%;
@include bp(800) {
font-size: .75rem;
padding: 1em 1.5em;
}
@include bp(1000) {
font-size: 1rem;
}
h1 {
font-family: "Audiowide", cursive;
color: $blue-dark;
font-size: 1.25em;
font-size: 5.5vw;
font-weight: 700;
margin-bottom: .25em;
@include bp(516) {
font-size: 2.25em;
font-size: 4.9vw;
}
@include bp(1080) {
font-size: 3.25em;
}
}
& > p,
& > h1 { text-align: center; }
& > p {
font-size: 0.667em;
font-size: 2.8vw;
margin-bottom: 1em;
@include bp(355) {
font-size: 0.667em;
}
@include bp(500) {
font-size: 1em;
}
@include bp(1300) {
font-size: 1.15em;
}
}
}
//tabs
div[class^="cat"] {
width: 100%;
//tabs lables
& > label {
background: darken($blue, 5%);
color: #fff;
cursor: pointer;
display: block;
font-weight: bold;
line-height: 1.4;
margin-bottom: 0.5em;
padding: 0.75em 0.5em;
transition: all 0.55s ;
&:hover { background: $blue; }
@include bp(800) {
font-size: 1.25em;
}
}
//hide catagory radios
& > input {
position: absolute;
z-index: -999;
&:focus + label {
background: darken($blue, 15%);
letter-spacing: 1px;
}
}
//hide questions till tab is picked
.question-wrap {
height: 100%;
max-height: 0;
opacity: 0;
overflow: hidden;
transition: all .75s cubic-bezier(0.19, 1, 0.22, 1);
width: 100%;
}
//open accordian style
& > input:checked ~ .question-wrap {
max-height: 1000px;
opacity: 1;
transition: all 1.95s cubic-bezier(0.19, 1, 0.22, 1) ;
}
///////////////////////////////
//question accordian styles //
/////////////////////////////
@at-root {
.question-wrap {
.question {
margin: 1em 0;
}
label {
color: lighten(#085078, 5%);
cursor: pointer;
display: block;
font-weight: bold;
margin-bottom: 0.5em;
@include bp(800) {
font-size: 1.25em;
}
}
input {
position: absolute;
z-index: -999;
top: -10000px;
&:focus + label {
color: darken($blue-dark, 5%);
}
}
input:not(:checked) ~ p {
height: 100%;
max-height: 0;
opacity: 0;
overflow: hidden;
transition: all .75s cubic-bezier(0.19, 1, 0.22, 1);
}
//open accordian style
input:checked ~ p {
max-height: 500px;
opacity: 1;
transition: all 1.95s cubic-bezier(0.19, 1, 0.22, 1);
}
}
}
}
input:focus {
border: 3px solid red;
outline: 3px solid red;
background: red;
}
a:focus {
color: $blue-dark;
font-weight: bold;
outline: none;
}
//NO JAVASCRIPT REQUIRED
Also see: Tab Triggers