JSFiddle - React, Tailwind, and code Playground
by trolleymusic
HTML
<script src="//cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.js"></script>
<select class="pretty">
<option>select:after</option>
<option>All</option>
<option>All</option>
<option>All</option>
<option>All</option>
</select>
<div class="hold">
<select class="pretty">
<option>div:after</option>
<option>All</option>
<option>All</option>
<option>All</option>
<option>All</option>
</select>
</div>
<div class="magic-hold">
<select class="pretty">
<option>div>svg</option>
<option>All</option>
<option>All</option>
<option>All</option>
<option>All</option>
</select>
<svg class="arrow" style="pointer-events: none;" pointer-events="none">
<polygon points="13,13 20,27 27,13"
style="fill:white;stroke:none;pointer-events:none;"/></svg>
</div>
<div class="hide">
<select class="pretty-hide">
<option>div:after + select z-index</option>
<option>All</option>
<option>All</option>
<option>All</option>
<option>All</option>
</select>
</div>
CSS
body {
background: cyan;
}
.hold,
.magic-hold,
.hide {
margin: 40px 0 0 0;
position: relative;
}
.pretty,
.hide,
.pretty-hide {
border-radius: 5px;
display: block;
width: 100%;
height: 40px;
background: #fff;
border: none;
font-size: 18px;
position: relative;
text-indent: 20px;
-webkit-appearance: none;
-moz-appearance: none;
}
.hold:after,
.pretty:after,
.magic-hold .arrow,
.hide:after {
background: #333;
border-radius: 0 3px 3px 0;
display: block;
position: absolute;
width: 40px;
right: 0;
top: 0;
height: 40px;
}
.hold:after,
.pretty:after,
.hide:after {
content: '▼';
pointer-events: none;
color: #fff;
text-align: center;
line-height: 40px;
}
.pretty-hide {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: transparent;
z-index: 200;
}
JavaScript
// developer.mozilla.org/en/CSS/pointer-events
// github.com/ausi/Feature-detection-technique-for-pointer-events
Modernizr.addTest('pointerevents', function(){
var element = document.createElement('x'),
documentElement = document.documentElement,
getComputedStyle = window.getComputedStyle,
supports;
if(!('pointerEvents' in element.style)){
return false;
}
element.style.pointerEvents = 'auto';
element.style.pointerEvents = 'x';
documentElement.appendChild(element);
supports = getComputedStyle &&
getComputedStyle(element, '').pointerEvents === 'auto';
documentElement.removeChild(element);
return !!supports;
});
console.log(Modernizr.pointerevents);