2

I have change the style for custom select box, even changed the arrow with css :after property.

Now my problem is when ever i clicked on down arrow drop down is not opening. Its correct because its on top of select box. How i can make it work so when user click on down arrow dropdown should open.

HTML

<div class="select-holder select-wrap poRel col-xs-4 col-sm-4 cntry-drop-down is-valid">
  <select class="select-item validate-me p-normal-text is-valid" data-validation-type="select_validation" id="ship_country" name="ship_country" data-default-msg="Country" autocomplete="off" tabindex="3">
    <option class="p-normal-text default-selected-value" value="" selected="selected">Country</option>
    <option class="p-normal-text" value="US" selected="">USA</option>
    <option class="p-normal-text" value="AU">Australia</option>
  </select>
</div>

CSS - used to place the arrow besides the select element

.select-holder:after {
    top: 12px;
    position: absolute;
    left: calc(100% - 50px);
    width: 0;
    height: 0;
    content: "\e259";
    display: inline-block;
    font-family: 'Glyphicons Halflings';
    font-size: inherit;
    text-rendering: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 1.2em;
}

Working Demo here.

How can I bind a click event on arrow, so it will open the select box.

1
  • You can't bind a click to a pseudo element (not with JS anyway, maybe there's a CSS hack). Commented Sep 25, 2015 at 2:42

1 Answer 1

2

You can use the CSS below:

.select-holder:after {
  pointer-events: none;
  /* the rest of your code */
}

It will prevent the click events on the arrow, so it will bubble to the parent, making it work as you want.

Updated CodePen

Sign up to request clarification or add additional context in comments.

1 Comment

I was aware about pointer-events: none, but didn't think on this way. very good work around.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.