skip to Main Content

I am using twitter bootstrap in order to have a select-option like list.

How can I avoid the small separation lines above (as depicted) and below the list of list items? See screeshot:

screenshot

In the following is the code visible. It will be the easiest to have a look at the jsfiddle:

https://jsfiddle.net/qqnkc9u3/3/

html:

<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
    D2ropdown
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
    <li><a class="my2" href="#"><!--data-value="action"--> Action</a></li>
    <li><a class="my2" href="#" data-value="another action">Another action</a></li>
    <li><a class="my2" href="#" data-value="something else here">Something else here</a></li>
    <li><a class="my2" href="#" data-value="separated link">Separated link</a></li>
</ul>

js:

$(".dropdown-menu li a").click(function(){
$(this).parents(".dropdown").find('.btn').html($(this).text() + ' <span ></span>');
$(this).parents(".dropdown").find('.btn').val($(this).data('value'));
});

css:

@charset "UTF-8";

@import url('https://fonts.googleapis.com/css?family=PT+Sans');

#dropdownMenu1 {
/*text-indent: -150px;*/
-webkit-appearance: none;
-moz-appearance: none;

font-family: 'PT Sans', sans-serif;
/*font-style: italic;*/
color: red;
font-size: 18px;
text-align: left;

width: 242px;
height: 42px;
border: 4px;
/*background-color: #e7eaf3;*/
background: url("http://www.adelepham.com/deepthoughts/gray-pattern.jpg") no-repeat 0 0;
/*color: #5B629B;*/
/*padding: 4px;*/
}

.my2 {
text-indent: -7px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;

font-style: italic;
font-family: 'PT Sans', sans-serif;
color: red;
font-size: 18px;

-webkit-appearance: none;
-moz-appearance: none;
width: 242px;
height: 42px;
/*border: 4px;*/
/*color: #5B629B;*/
background: url("http://www.adelepham.com/deepthoughts/gray-pattern.jpg") no-repeat 0 0;
}

3

Answers


  1. Just get rid of the padding (updated JSFiddle):

    .dropdown-menu {
      padding: 0;
    }
    

    You can also do this:

    .dropdown-menu {
      padding: 0;
      margin: 0;
    }
    

    to get rid of the little 1 or 2 px space between the button and the menu itself.

    Login or Signup to reply.
  2. Add padding: 0; margin: 0; to your #dropdown-menu.

    jsFiddle

    Login or Signup to reply.
  3. You can try to remove padding and margin of the ul like:

    .dropdown-menu {
       padding: 0px;
       margin: 0px;
    }
    

    Fiddle: https://jsfiddle.net/qqnkc9u3/8/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search