JSFiddle - React, Tailwind, and code Playground
by mackry
HTML
<div id="wrapper" class="clearfix">
<h1>What are your goals?</h1>
<div id="goal-list">
<ul>
<li>Be proactive</li>
<li>Feel less stressed</li>
<li>Quit smoking</li>
<li>Drink less</li>
<li>Lose weight</li>
<li>Enjoy my work</li>
<li>Sleep</li>
<li>Give back</li>
<li>Achieve carrer goals</li>
<li>Volunteer</li>
</ul>
<p>Our experts suggest you pick <strong>no more than three</strong>.</p>
</div>
</div>
CSS
#wrapper {
font-family: 'helvetica neue', arial, sans-serif;
margin: 50px auto 0;
padding-bottom: 30px;
width: 725px;
}
h1, h3 {
font-weight: bold;
}
h1 {
color: #00ADEF;
font-size: 34px;
margin-bottom: 30px;
text-align: center;
}
#goal-list {
background: #F7F7F7;
float: left;
padding: 30px;
width: 100%;
}
#goal-list ul {
-moz-column-count: 2;
-webkit-column-count: 2;
-moz-column-gap: 30px;
-webkit-column-gap: 30px;
-webkit-column-width: 20%;
}
#goal-list li {
background: #E5E5E5;
border: 1px solid #F7F7F7;
color: #666666;
cursor: pointer;
font-size: 13px;
font-weight: bold;
margin-top: 10px;
padding: 7px;
text-align: center;
-moz-border-radius: 40px;
-webkit-border-radius: 40px;
border-radius: 40px;
}
#goal-list li:hover {
background: #D5D5D5;
}
#goal-list li:active {
background: #AAAAAA;
}
#goal-list li.active {
background-color: #00ADEF;
border: 1px solid #00A2E0;
border-bottom-color: #0095CE;
color: #FFFFFF;
text-shadow: 0 1px rgba(0,0,0,.1);
-moz-box-shadow: 0 1px rgba(0,0,0,.1);
-webkit-box-shadow: 0 1px rgba(0,0,0,.1);
box-shadow: 0 1px rgba(0,0,0,.1);
}
#goal-list li:nth-child(1),
#goal-list li:nth-child(6) {
margin-top: 0;
}
#goal-list p {
background: #F0F0F0;
border-top: 1px dashed #DEDEDE;
color: #888888;
font-size: 13px;
margin: 30px -30px -30px -30px;
padding: 10px 0;
text-align: center;
-webkit-transition: all 0.2s ease-out;
-moz-transition: all 0.2s ease-out;
-ms-transition: all 0.2s ease-out;
-o-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}
#goal-list strong {
font-weight: bold;
}
.clearfix:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
JavaScript
$(document).ready(function() {
var $goals = $('#goal-list li');
count = 0;
$goals.toggle(function() {
if (count < 3) {
count++;
$(this).addClass('active');
} else {
var $alert = $('#goal-list p').css({
color: '#6F6B46',
background: '#FFFCE1'
});
setTimeout(function() {
$alert.css({
color: '#888888',
background: '#F0F0F0'
});
}, 5000);
}
}, function() {
count--;
$(this).removeClass('active');
});
});