CSS Only Playground
body, html { margin: 0; font-family: arial; height: 100vh; background: #ccc; }
*, *:before, *:after { box-sizing: border-box; }
.nav-mobile {
position: fixed;
top: 0;
left: 0;
width: 100%;
background: #446CB3;
color: #FFF;
padding: 0;
margin: 0;
cursor: auto;
font-size: 18px;
list-style-type: none;
z-index: 999999;
box-shadow: 0 5px 5px -5px #333;
&:after { content: ""; display: table; clear: both; }
svg {
height: 45px;
width: 65px;
padding: 9px;
path { fill: #fff; }
&.icon-close {
display: none;
padding: 15px;
}
}
li {
width: 100%;
height: 45px;
line-height: 46px;
text-align: center;
float: left;
a {
display: block;
color: #333;
width: 100%;
height: 100%;
text-decoration: none;
}
}
.menu-button {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
margin: 0;
cursor: pointer;
display: block;
&:after {
opacity: 0;
top: 45px;
content: "";
width: 100vw;
display: block;
position: fixed;
height: 100vh;
background: rgba(0,0,0,0.5);
content: "";
z-index: 9;
pointer-events: none;
transition: opacity 0.2s cubic-bezier(0,0,0.3,1);
transition-delay: 0.1s;
}
}
#menu-toggle {
display: none;
&.active ~ .menu-button,
&:checked ~ .menu-button {
.icon-close { display: block; }
.icon-open { display: none; }
&:after {
opacity: 1;
pointer-events: auto;
transition: opacity 0.3s cubic-bezier(0,0,0.3,1);
}
}
&.active ~ .menu-sidebar,
&:checked ~ .menu-sidebar {
transform: translateX(0);
transition: transform 0.3s cubic-bezier(0,0,0.3,1);
}
}
.menu-container {
width: 65px;
float: left;
cursor: pointer;
position: absolute;
.menu-sidebar {
box-shadow: 5px 0 5px -5px #333;
display: block;
width: 65vw;
bottom: 0;
background: white;
color: #333;
position: fixed;
z-index: 9999999;
transform: translateX(-405px);
transition: transform 0.3s cubic-bezier(0,0,0.3,1);
top: 45px;
list-style-type: none;
padding: 0;
max-width: 400px;
.arrow {
position: absolute;
line-height: 50px;
font-size: 32px;
color: #555;
top: 0;
z-index: 0;
&.left { left: 25px; }
&.right { right: 25px; }
}
li {
height: 55px;
line-height: 55px;
font-size: 16px;
text-align: left;
position: relative;
border-bottom: 1px solid rgba(0,0,0,0.1);
padding-left: 20px;
&:hover { background: #eee; }
.menu-sub {
position: fixed;
top: 0;
right: 0;
bottom: 0;
width: 0;
overflow: hidden;
background: white;
visibility: hidden;
transition: all 0.3s cubic-bezier(0,0,0.3,1);
border-left: 1px solid #ccc;
list-style-type: none;
padding: 0;
margin: 0;
z-index: 2;
max-width: 400px;
li { overflow: hidden; }
.menu-sub-title { padding-left: 50px; }
}
.submenu-label {
cursor: pointer;
width: 100%;
height: 100%;
display: block;
}
.submenu-toggle {
display: none;
&.active ~ .menu-sub,
&:checked ~ .menu-sub {
width: 65vw;
visibility: visible;
z-index: 1;
transition: width 0.35s cubic-bezier(0,0,0.3,1);
}
}
}
}
}
}
.carousel-container {
list-style-type: none;
padding: 0;
margin: 30px auto;
width: 550px;
height: 338px;
border-radius: 5px;
position: relative;
z-index: 0;
.arrow {
cursor: pointer;
background: rgba(0,0,0,0.5);
color: rgba(255,255,255,0.5);
display: block;
width: 50px;
font-size: 62px;
text-align: center;
bottom: 0;
top: 0;
line-height: 330px;
position: absolute;
z-index: 9999;
padding-bottom: 4px;
padding-top: 2px;
border-radius: 2px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
&.next {
left: 0px;
background: linear-gradient(to right, rgba(0,0,0,0.5), transparent)
}
&.back {
right: 0px;
background: linear-gradient(to left, rgba(0,0,0,0.5), transparent)
}
&:hover { color: rgba(255,255,255,1); }
}
li:nth-child(1) > .dot { margin-left: 44.6% }
.carousel-content {
height: 0;
overflow: hidden;
line-height: 22px;
background: #000;
position: absolute;
top: 0px;
border-radius: 5px;
box-shadow: 0 5px 5px -5px #333;
list-style-type: none;
padding: 0;
img {
opacity: 0;
padding: 0;
position: absolute;
left: 0;
top: 0;
width: 100%;
border-radius: 5px;
transition: 0.2s ease-in;
}
}
.dot {
float: left;
cursor: pointer;
opacity: 1;
width: 12px;
height: 12px;
background: rgba(255,255,255,0.5);
position: relative;
margin-top: 56%;
border-radius: 50%;
z-index: 999;
margin-right: 8px;
display: block;
&:hover { background: #fff; }
}
.carousel-toggle {
display: none;
&:checked + .dot,
&.active + .dot { background: #fff; }
&:checked ~ .carousel-content,
&.active ~ .carousel-content {
height: 100%;
width: 100%;
img { opacity: 1; }
}
}
}
.tab-container {
list-style-type: none;
padding: 0;
margin: 60px auto;
max-width: 350px;
position: relative;
background: #fff;
&:after { content: ""; display: table; clear: both; }
ul { list-style-type: none; padding: 0; }
.arrows {
display: block;
width: 60px;
font-size: 32px;
bottom: 10px;
right: 0px;
position: absolute;
label {
display: inline-block;
cursor: pointer;
color: #aaa;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
margin-left: 5px;
&:hover { color: #333; }
}
}
.tab-content-container {
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
height: 0;
opacity: 0;
overflow: hidden;
line-height: 22px;
background: #fff;
position: absolute;
top: 42px;
padding: 0px 40px 0 20px;
border: 2px solid #446CB3;
border-top: 0;
box-shadow: 0 5px 5px -5px #333;
.tab-content {
opacity: 0;
padding: 15px 0;
min-height: 185px;
transition: opacity 0.1s ease-in;
}
}
.tab {
outline: 0;
float: left;
cursor: pointer;
opacity: 1;
width: 25%;
line-height: 40px;
display: block;
margin: 0;
position: relative;
background: #446CB3;
color: #fff;
text-align: center;
border-top: 2px solid #446CB3;
border-right: 2px solid #446CB3;
&.l-b { border-left: 2px solid #446CB3; }
&:hover { background: #365690; }
}
.tab-toggle {
display: none;
&.active + .tab,
&:checked + .tab {
background: #fff;
color: #333;
}
&.active ~ .tab-content-container,
&:checked ~ .tab-content-container {
height: auto;
opacity: 1;
.tab-content {
opacity: 1;
label { opacity: 1; }
}
}
}
}
.accordion-container {
width: 300px;
margin: 60px auto;
border: 2px solid #446CB3;
border-radius: 4px;
box-shadow: 0 5px 5px -5px #333;
list-style-type: none;
padding: 0;
ul { list-style-type: none; padding-left: 0; }
.accordion-category {
position: relative;
background: #fff;
.accordion-title {
padding-left: 20px;
height: 40px;
font-size: 18px;
line-height: 40px;
background: #446CB3;
color: #fff;
position: relative;
display: block;
cursor: pointer;
&:hover {
background: #365690;
}
}
.accordion-items {
max-height: 0;
height: 0;
margin: 0;
overflow: hidden;
transition: 0.6s ease-in;
li {
padding: 5px 20px;
&:first-child { padding-top: 10px }
&:last-child { padding-bottom: 10px; }
}
}
input {
display: none;
&.active ~ .accordion-items,
&:checked ~ .accordion-items {
height: auto;
max-height: 900px;
-webkit-transform: translate3d(0,0,0);
}
&.active ~ .accordion-title,
&:checked ~ .accordion-title,
&:hover ~ .accordion-title {
&:after {
content: "\203A";
position: absolute;
width: 40px;
font-size: 32px;
right: 0;
padding-left: 15px;
top: 0;
bottom: 0;
transform: rotate(90deg);
}
}
}
}
}
.modal-container {
margin: 60px auto;
padding-top: 0px;
position: relative;
width: 160px;
.modal-btn {
display: block;
margin: 0 auto;
color: #fff;
width: 160px;
height: 50px;
line-height: 50px;
background: #446CB3;
font-size: 22px;
border: 0;
border-radius: 3px;
cursor: pointer;
text-align: center;
box-shadow: 0 5px 5px -5px #333;
transition: background 0.3s ease-in;
&:hover { background: #365690; }
}
.modal-content,
.modal-backdrop {
height: 0;
width: 0;
opacity: 0;
visibility: hidden;
overflow: hidden;
cursor: pointer;
transition: opacity 0.2s ease-in;
}
.modal-close {
color: #aaa;
position: absolute;
right: 5px;
top: 5px;
padding-top: 3px;
background: #fff;
font-size: 16px;
width: 25px;
height: 25px;
font-weight: bold;
text-align: center;
cursor: pointer;
&:hover { color: #333; }
}
.modal-content-btn {
position: absolute;
text-align: center;
cursor: pointer;
bottom: 20px;
right: 30px;
background: #446CB3;
color: #fff;
width: 50px;
border-radius: 2px;
font-size: 14px;
height: 32px;
padding-top: 9px;
font-weight: normal;
&:hover { color: #fff; background: #365690; }
}
#modal-toggle {
display: none;
&.active ~ .modal-backdrop,
&:checked ~ .modal-backdrop {
background-color: rgba(0, 0, 0, 0.6);
width: 100vw;
height: 100vh;
position: fixed;
left: 0;
top: 0;
z-index: 9;
visibility: visible;
opacity: 1;
transition: opacity 0.2s ease-in;
}
&.active ~ .modal-content,
&:checked ~ .modal-content {
opacity: 1;
background-color: #fff;
max-width: 400px;
width: 400px;
height: 280px;
padding: 10px 30px;
position: fixed;
left: calc(50% - 200px);
top: 12%;
border-radius: 4px;
z-index: 999;
pointer-events: auto;
cursor: auto;
visibility: visible;
box-shadow: 0 3px 7px rgba(0, 0, 0, 0.6);
@media (max-width: 400px) { left: 0; }
}
}
}
.tooltip-container {
margin: 60px auto;
padding-top: 0px;
position: relative;
width: 160px;
.tooltip-btn {
display: block;
margin: 0 auto;
color: #fff;
width: 160px;
height: 50px;
line-height: 50px;
background: #446CB3;
font-size: 22px;
border: 0;
border-radius: 3px;
cursor: pointer;
text-align: center;
box-shadow: 0 5px 5px -5px #333;
transition: background 0.3s ease-in;
&:hover { background: #365690; }
&.tooltip-toggle:hover ~ .tooltip-content {
opacity: 1;
background-color: #fff;
max-width: 400px;
width: 200px;
min-height: 70px;
padding: 0px 20px;
position: absolute;
left: calc(50% - 100px);
top: 145%;
border-radius: 4px;
z-index: 999;
pointer-events: auto;
cursor: auto;
visibility: visible;
overflow: visible;
box-shadow: 0 3px 7px rgba(0, 0, 0, 0.6);
@media (max-width: 400px) { left: 0; };
&:before {
content: "";
width: 0;
height: 0;
border-style: solid;
border-width: 0 10px 10px 10px;
border-color: transparent transparent #ffffff transparent;
position: absolute;
top: -10px;
left: 30px;
}
}
}
.tooltip-content,
.tooltip-backdrop {
height: 0;
width: 0;
opacity: 0;
visibility: hidden;
overflow: hidden;
transition: opacity 0.2s ease-in;
}
#tooltip-toggle {
display: none;
&.active ~ .tooltip-backdrop,
&:checked ~ .tooltip-backdrop {
background-color: transparent;
width: 100vw;
height: 100vh;
position: fixed;
left: 0;
top: 0;
z-index: 9;
visibility: visible;
opacity: 1;
transition: opacity 0.2s ease-in;
}
&.active ~ .tooltip-content,
&:checked ~ .tooltip-content {
opacity: 1;
background-color: #fff;
max-width: 400px;
width: 200px;
min-height: 70px;
padding: 0px 20px;
position: absolute;
left: calc(50% - 100px);
top: 145%;
border-radius: 4px;
z-index: 999;
pointer-events: auto;
visibility: visible;
overflow: visible;
box-shadow: 0 3px 7px rgba(0, 0, 0, 0.6);
@media (max-width: 400px) { left: 0; };
&:before {
content: "";
width: 0;
height: 0;
border-style: solid;
border-width: 0 10px 10px 10px;
border-color: transparent transparent #ffffff transparent;
position: absolute;
top: -10px;
left: 30px;
}
}
}
}
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
// Optional jQuery class toggle for added robustness.
/*
var labelID;
$('.check label').click(function() {
labelID = $(this).attr('for');
$('#' + labelID).toggleClass('active');
});
$('.radio label').click(function() {
labelID = $(this).attr('for');
$('.radio input').removeClass('active');
$('#' + labelID).addClass('active');
});
*/
<ul class="nav-mobile check">
<li>CSS-only Playground</li>
<li class="menu-container">
<input id="menu-toggle" type="checkbox">
<label for="menu-toggle" class="menu-button">
<svg class="icon-open" viewBox="0 0 24 24"><path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"></path></svg>
<svg class="icon-close" viewBox="0 0 100 100">
<path d="M83.288 88.13c-2.114 2.112-5.575 2.112-7.69 0L53.66 66.188c-2.113-2.112-5.572-2.112-7.686 0l-21.72 21.72c-2.114 2.113-5.572 2.113-7.687 0l-4.693-4.692c-2.114-2.114-2.114-5.573 0-7.688l21.72-21.72c2.112-2.115 2.112-5.574 0-7.687L11.87 24.4c-2.114-2.113-2.114-5.57 0-7.686l4.842-4.842c2.113-2.114 5.57-2.114 7.686 0l21.72 21.72c2.114 2.113 5.572 2.113 7.688 0l21.72-21.72c2.115-2.114 5.574-2.114 7.688 0l4.695 4.695c2.112 2.113 2.112 5.57-.002 7.686l-21.72 21.72c-2.112 2.114-2.112 5.573 0 7.686L88.13 75.6c2.112 2.11 2.112 5.572 0 7.687l-4.842 4.84z"/>
</svg>
</label>
<ul class="menu-sidebar">
<li><a href="#">Item</a></li>
<li><a href="#">Item</a></li>
<li><a href="#">Item</a></li>
<li>
<input type="checkbox" id="sub-one" class="submenu-toggle">
<label class="submenu-label" for="sub-one">Category</label>
<div class="arrow right">›</div>
<ul class="menu-sub">
<li class="menu-sub-title">
<label class="submenu-label" for="sub-one">Back</label>
<div class="arrow left">‹</div>
</li>
<li><a href="#">Sub-item</a></li>
<li><a href="#">Sub-item</a></li>
<li><a href="#">Sub-item</a></li>
<li><a href="#">Sub-item</a></li>
</ul>
</li>
<li>
<input type="checkbox" id="sub-two" class="submenu-toggle">
<label class="submenu-label" for="sub-two">Category</label>
<div class="arrow right">›</div>
<ul class="menu-sub">
<li class="menu-sub-title">
<label class="submenu-label" for="sub-two">Back</label>
<div class="arrow left">‹</div>
</li>
<li><a href="#">Sub-item</a></li>
<li><a href="#">Sub-item</a></li>
<li><a href="#">Sub-item</a></li>
<li><a href="#">Sub-item</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<br /><br /><br />
<ul class="carousel-container radio">
<li>
<input class="carousel-toggle" id="slide-1" type="radio" name="c-toggle" checked/>
<label class="dot" for="slide-1"></label>
<ul class="carousel-content">
<li>
<img src="http://www.spacebuckets.com/gal/1-1.jpg"/>
<label class="arrow back" for="slide-2">› </label>
<label class="arrow next" for="slide-4">‹</label>
</li>
</ul>
</li>
<li>
<input class="carousel-toggle" id="slide-2" type="radio" name="c-toggle" />
<label class="dot" for="slide-2"></label>
<ul class="carousel-content">
<li>
<img src="http://www.spacebuckets.com/gal/2-1.jpg"/>
<label class="arrow back" for="slide-3">› </label>
<label class="arrow next" for="slide-1">‹</label>
</li>
</ul>
</li>
<li>
<input class="carousel-toggle" id="slide-3" type="radio" name="c-toggle" />
<label class="dot" for="slide-3"></label>
<ul class="carousel-content">
<li>
<img src="http://www.spacebuckets.com/gal/3-1.jpg"/>
<label class="arrow back" for="slide-4">› </label>
<label class="arrow next" for="slide-2">‹</label>
</li>
</ul>
</li>
<li>
<input class="carousel-toggle" id="slide-4" type="radio" name="c-toggle" />
<label class="dot" for="slide-4"></label>
<ul class="carousel-content">
<img src="http://www.spacebuckets.com/gal/4-1.jpg"/>
<label class="arrow back" for="slide-1">› </label>
<label class="arrow next" for="slide-3">‹</label>
</ul>
</li>
</ul>
<hr />
<ul class="tab-container radio">
<li>
<input class="tab-toggle" id="tab-1" type="radio" name="toggle" checked />
<label data-title="Tab 1" class="tab l-b" for="tab-1">Tabs</label>
<ul class="tab-content-container">
<li class="tab-content">
This is a testing text to test the tab content container. Lorem Ipsum dolor sit amet! Consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
This is a testing text to test the tab content container. Lorem Ipsum dolor sit amet!
<div class="arrows">
<label class="back" for="tab-4">‹</label>
<label class="next" for="tab-2">› </label>
</div>
</li>
</ul>
</li>
<li>
<input class="tab-toggle" id="tab-2" type="radio" name="toggle" />
<label class="tab" for="tab-2">Are</label>
<ul class="tab-content-container">
<li class="tab-content">
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
<div class="arrows">
<label class="back" for="tab-1">‹</label>
<label class="next" for="tab-3">› </label>
</div>
</li>
</ul>
</li>
<li>
<input class="tab-toggle" id="tab-3" type="radio" name="toggle"/>
<label class="tab" for="tab-3">Pretty</label>
<ul class="tab-content-container">
<li class="tab-content">
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
<div class="arrows">
<label class="back" for="tab-2">‹</label>
<label class="next" for="tab-4">› </label>
</div>
</li>
</ul>
</li>
<li>
<input class="tab-toggle" id="tab-4" type="radio" name="toggle"/>
<label class="tab" for="tab-4">Cool</label>
<ul class="tab-content-container">
<li class="tab-content">
This is the final content for the tab example.
<div class="arrows">
<label class="back" for="tab-3">‹</label>
<label class="next" for="tab-1">› </label>
</div>
</li>
</ul>
</li>
</ul>
<br /><br /><br /><br /><br /><br /><br /><br />
<hr />
<ul class="accordion-container radio">
<li class="accordion-category">
<input type="radio" name="a-toggle" id="one" checked>
<label for="one" class="accordion-title">Accordions</label>
<ul class="accordion-items">
<li>Item One</li>
<li>Item Two</li>
<li>Item Three</li>
</ul>
</li>
<li class="accordion-category">
<input id="two" type="radio" name="a-toggle">
<label for="two" class="accordion-title">Condense</label>
<ul class="accordion-items">
<li>Item A</li>
<li>Item B</li>
</ul>
</li>
<li class="accordion-category">
<input id="tre" type="radio" name="a-toggle">
<label for="tre" class="accordion-title">Stuff</label>
<ul class="accordion-items">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
</ul>
</ul>
</div>
<hr />
<div class="modal-container check">
<input id="modal-toggle" type="checkbox">
<label class="modal-btn" for="modal-toggle">Modal</label>
<label class="modal-backdrop" for="modal-toggle"></label>
<div class="modal-content">
<label class="modal-close" for="modal-toggle">✕</label>
<h2>Modal title</h2><hr />
<p>Hello from inside the modal!</p>
<label class="modal-content-btn" for="modal-toggle">OK</label>
</div>
</div>
<hr />
<div class="tooltip-container check">
<input id="tooltip-toggle" type="checkbox">
<label class="tooltip-btn" for="tooltip-toggle">Tooltip click</label>
<label class="tooltip-backdrop" for="tooltip-toggle"></label>
<div class="tooltip-content">
<p>Hello from inside the CSS tooltip!</p>
</div>
</div>
<div class="tooltip-container">
<div class="tooltip-btn tooltip-toggle">Tooltip hover</div>
<div class="tooltip-content">
<p>Hello from inside the CSS tooltip!</p>
</div>
</div>
<br /><br /><br />