Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8845413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:44:02+00:00 2026-06-14T11:44:02+00:00

I need to create custom styled select drop downs (there are three) form inputs.

  • 0

I need to create custom styled select drop downs (there are three) form inputs. I have used jquery to accomplish this as I’m not aware of a good way to do this in CSS. The issue I’m having is that despite messing with the z-index of the various elements, the menu’s drop down BEHIND the other form inputs. I have looked at the answers to each of:
Why is the drop down menu hiding behind jQuery button? (basically the exact problem i’m having – no good solution found)
Drop down being hidden behind banner button

However the solutions don’t seem to work for me. You can see a working version of the problem here: http://jsfiddle.net/SANdM/5/

This is the select code (there are 3 of these):

<select name="data[Product][to_relationship]" class="input-medium" id="to_relationship">
  <option value=""></option>
  <option value="F|1|Mother">Mother</option>
  <option value="M|1|Father">Father</option>
  <option value="M|2|Boyfriend">Boyfriend</option>
  <option value="F|2|Girlfriend">Girlfriend</option>
  <option value="F|3|Friend (F)">Friend (F)</option>
  <option value="M|3|Friend (M)">Friend (M)</option>
</select> 

This is the jquery code to convert the select into a ul:

$('select').each(function() {
    //esape the square brackets in the name attribute


    function $escape(string) {
        return string.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g, '\\$1');
    }

    function $unescape(string) {
        return string.replace(/\\/g, '');
    }
    // create new ul to replace select
    $(this).after('<ul class="select"></ul>');

    // define objects
    var $this = $(this); // exising <select> element
    var $select = $this.next('ul.select').eq(0); // new <ul> version of the select
    var $form = $this.parents('form').eq(0); // the containing form
    // define variables
    var id = $this.attr('id'); // id of the <select>
    // name of the <select>
    var name = $escape($this.attr('name')); // name of the <select>
    // wrap the new ul in a div we can use to anchor positioning
    $select.wrap('<div class="select-container"/>');

    // set a custom data attribute to maintain the name from the original select on the new ul
    $select.data('name', name);
    $select.attr('id', id);
    // grab the first <option> item in the <select> and populate the currently selected (first) option in the ul
    $select.append('<li class="current">' + $('option', $this).eq(0).html() + '<span class="value">' + $('option', $this).eq(0).val() + '</span></li>');

    // duplicate the rest of <option>s in select to ul
    $('option', $this).each(function() {
        $select.append('<li>' + $(this).html() + '<span class="value">' + $(this).val() + '</span></li>');
    });

    // add hidden field to form to capture value from ul
    $form.append('<input type="hidden" name="' + $unescape(name) + '" value="' + $('option', $this).eq(0).val() + '" />');

    // remove the old <select> now that we've built our new ul
    $this.remove();
});
$('.select li.current').click(function() {

    // toggle the visible state of the ul
    $(this).parents('ul.select').toggleClass('active');
});

$('.select li:not(.current)').click(function() {

    // objects
    var $this = $(this);
    var $select = $this.parents('ul').eq(0);
    var $hidden = $('input[name=' + $select.data('name') + ']');
    var $current = $('.current', $select);

    // set the current text
    $current.html($this.html());

    // close the ul
    $select.removeClass('active');

    // populate the hidden input with the new value
    $hidden.val($this.find('.value').text());
});
$('body, html').mouseup(function() {
    if ($('.select.active').length != 0) {$('.select.active').removeClass('active');}
});​

And the CSS to style it is:

.select-container {
    float: left;
    height: 40px;
    min-width: 170px;
    margin-right: 10px;
    position:relative;
}
.pull-left{float:left}


ul.select {
    list-style: none;
    color: #ee3925;
    width: 170px;
    border: 3px solid #ee3925;
    -webkit-border-radius: 8px;
    -moz-border-radius: 8px;
      border-radius: 8px;
    position: absolute;
    background-color:#FFF;
}


ul.select li {
    min-width: 100px;
    padding:0 10px;
    height: 30px;
    line-height: 30px;
    border: 0px solid #FFF;
    -webkit-border-radius: 8px;
    -moz-border-radius: 8px;
    border-radius: 8px;
    background-color:#FFF;
}

ul.select li:not(.current) {
   display: none;

}

ul.select.active li {
    display: block;
}

ul.select li.current {
    cursor: pointer;
    font-weight:bold;
}

ul.select li:hover {
    cursor: pointer;
}

.value{display:none;}

​
Any help would be greatly appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:44:03+00:00Added an answer on June 14, 2026 at 11:44 am

    just set z-index css property of element active class:

    .active{z-index:9999}
    

    http://jsfiddle.net/2FbWg/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create a custom component which consist of a drop down box,
I have a multipart form to create a custom stamp. I have the main
I need to create a custom checkBox control. So far I have: So at
Is it possible to create a custom theme and have it used as the
I need to create a custom control containing a combobox whose popup will have
I'm using jQuery.flot to create custom charts in my project, but I need invert
I need create custom dialog and put JPanel into it. Is it possible?
Need to create a custom DNS name server using C which will check against
I need to create a custom user interface using extJS/JSP which will allow me
I need to create a custom json for the jit library. Should I use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.