JSFiddle - React, Tailwind, and code Playground
by Craig Robertson
HTML
<div class="container">
<h2>Dropdown Component</h2>
<!-- THIS BIT FUNDS START -->
<section class="main clearfix">
<select id="cd-dropdown" name="cd-dropdown" class="cd-select">
<option value="-1" selected>Funds in your portfolio (3)</option>
<option value="1">fund 1£60,000</option>
<option value="2">Fund 2 £40,000</option>
<option value="3">Fund 3 £24,000</option>
<option value="4">View all funds ></option>
<option value="5">Fund 4 £24,000</option>
</select>
</section>
<!-- THIS BIT FUNDS END -->
</div>
CSS
.cd-dropdown, .cd-select {
position: relative;
width:100%;
margin: 20px auto;
display: block;
font-family:StandardLife-Light_Beta5, Arial, sans-serif;
}
.cd-dropdown > span {
width: 100%;
height: 60px;
line-height: 60px;
color:#087c89;
font-weight: 700;
font-size: 16px;
background: #fff;
display: block;
padding: 0 50px 0 30px;
position: relative;
cursor: pointer;
}
.cd-dropdown > span:after {
content: '\25BC';
position: absolute;
right: 0px;
top: 15%;
width: 50px;
text-align: center;
font-size: 12px;
padding: 10px;
/*height: 70%;*/
line-height: 24px;
border-left:2px solid #ddd;
}
.cd-dropdown.cd-active > span:after {
content: '\25B2';
}
.cd-dropdown ul {
list-style-type: none;
margin: 0;
padding: 0;
display: block;
position: relative;
}
.cd-dropdown ul li {
display: block;
}
.cd-dropdown ul li span {
width: 100%;
background: #fff;
line-height: 60px;
padding: 0 50px 0 30px;
display: block;
color:#36b0be;
cursor: pointer;
font-weight: 700;
}
.cd-dropdown > span,
.cd-dropdown ul li:nth-last-child(-n+3) span {
box-shadow: 0 1px 1px rgba(0,0,0,0.1);
}
.cd-dropdown ul {
position: absolute;
top: 0px;
width: 100%;
}
.cd-dropdown ul li {
position: absolute;
width: 100%;
}
.cd-active.cd-dropdown > span {
color:#087c89;
}
.cd-active.cd-dropdown > span,
.cd-active.cd-dropdown ul li span {
box-shadow: 0 1px 1px rgba(0,0,0,0.1);
}
.cd-active.cd-dropdown ul li span {
-webkit-transition: all 0.2s linear 0s;
-moz-transition: all 0.2s linear 0s;
-ms-transition: all 0.2s linear 0s;
-o-transition: all 0.2s linear 0s;
transition: all 0.2s linear 0s;
}
.cd-active.cd-dropdown ul li span:hover {
background: #087c89;
color: #fff;
}
JavaScript
/* Modernizr 2.6.2 (Custom Build) | MIT & BSD
* Build: http://modernizr.com/download/#-csstransitions-touch-shiv-cssclasses-teststyles-testprop-testallprops-prefixes-domprefixes-load
*/
;window.Modernizr=function(a,b,c){function z(a){j.cssText=a}function A(a,b){return z(m.join(a+";")+(b||""))}function B(a,b){return typeof a===b}function C(a,b){return!!~(""+a).indexOf(b)}function D(a,b){for(var d in a){var e=a[d];if(!C(e,"-")&&j[e]!==c)return b=="pfx"?e:!0}return!1}function E(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:B(f,"function")?f.bind(d||b):f}return!1}function F(a,b,c){var d=a.charAt(0).toUpperCase()+a.slice(1),e=(a+" "+o.join(d+" ")+d).split(" ");return B(b,"string")||B(b,"undefined")?D(e,b):(e=(a+" "+p.join(d+" ")+d).split(" "),E(e,b,c))}var d="2.6.2",e={},f=!0,g=b.documentElement,h="modernizr",i=b.createElement(h),j=i.style,k,l={}.toString,m=" -webkit- -moz- -o- -ms- ".split(" "),n="Webkit Moz O ms",o=n.split(" "),p=n.toLowerCase().split(" "),q={},r={},s={},t=[],u=t.slice,v,w=function(a,c,d,e){var f,i,j,k,l=b.createElement("div"),m=b.body,n=m||b.createElement("body");if(parseInt(d,10))while(d--)j=b.createElement("div"),j.id=e?e[d]:h+(d+1),l.appendChild(j);return f=["­",'<style id="s',h,'">',a,"</style>"].join(""),l.id=h,(m?l:n).innerHTML+=f,n.appendChild(l),m||(n.style.background="",n.style.overflow="hidden",k=g.style.overflow,g.style.overflow="hidden",g.appendChild(n)),i=c(l,a),m?l.parentNode.removeChild(l):(n.parentNode.removeChild(n),g.style.overflow=k),!!i},x={}.hasOwnProperty,y;!B(x,"undefined")&&!B(x.call,"undefined")?y=function(a,b){return x.call(a,b)}:y=function(a,b){return b in a&&B(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=u.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(u.call(arguments)));return...