0

enter image description here

http://codepen.io/leongaban/pen/ztIua

I have a custom styled select here with a svg dropdown arrow on top of it. However if you try to click on the arrow itself it does not open the select because of some sort of layered hierarchy. Is there anyway to disable that div from being clickable with just CSS?

<h2>
    <div class="drop_arrow"></div>
    <select id="getRoute">
        <option class="routeSelector">Onboarding</option>
        <option class="routeSelector">Engagement</option>
        <option class="routeSelector">Popular Searches</option>
        <option class="routeSelector">Unregistered</option>
    </select>
</h2>

#getRoute {
    margin-right: 5px;
    margin-left: -20px;
    padding: 5px;
    width: 180px;
    font: 16px LatoBold;
    -webkit-appearance: none;
}

.drop_arrow {
    position: relative;
    float: left;
    top: 10px;
    left: 150px;
    width: 18px;
    height: 12px;
    background-position: -520px 0px;
    background-size: 1600px 1600px;
    background-image: url(http://leongaban.com/images/dash.svg), none;
-moz-user-select: none; 
    -khtml-user-select: none; 
    -webkit-user-select: none; 
    -o-user-select: none; 
}
Leon Gaban
  • 36,509
  • 115
  • 332
  • 529

3 Answers3

2

I believe i have found a solution.

adding the JS:

function dropDown(){
  var dropdown = document.getElementById('getRoute');
    var event = document.createEvent('MouseEvents');
    event.initMouseEvent('mousedown', true, true, window);
    dropdown.dispatchEvent(event);
}

and triggering this on the arrow click should do the trick .

http://codepen.io/anon/pen/xiDmw

Pogrindis
  • 7,755
  • 5
  • 31
  • 44
2

Give the drop down list relative position (so that it is above the arrow in the stack order), and a transparent background (so the arrow is visible through the drop down):

#getRoute {
    ...
    background-color: transparent;
    position: relative;
}

http://codepen.io/anon/pen/bcjgJ

gilly3
  • 87,962
  • 25
  • 144
  • 176
1

css is for display not for click events.

You need to use js to forward the click to the element you want

Zied Hamdi
  • 2,400
  • 1
  • 25
  • 40