简体   繁体   English

创建自定义下拉菜单

[英]creating customized dropdown menu

I am trying to create a dropdown menu which is same as the image below. 我正在尝试创建一个与下图相同的下拉菜单。

. 在此输入图像描述

 <div class="dropdown dropdown-select signup-dd">
   <button class="btn btn-default dropdown-toggle signup-btn"  type="button" id="dropdownMenu1" data-toggle="dropdown" aria- expanded="true">
    Select Title
     <span class="caret downarrow-signup"></span>
   </button>
   <ul class="dropdown-menu ul-signup" role="menu" aria-labelledby="dropdownMenu1">
      <%# @themes.each do |t| %>
       <li role="presentation" class="dd-li">
       <a role="menuitem" tabindex="-1" href="javascript:void(0);" onclick="$('#dropdownMenu122').text('Mr.');$('#user_title').val('<%="Mr."%>');" ><%="Mr."%></a></li>
       <li role="presentation" class="dd-li" >
       <a role="menuitem" tabindex="-1" href="javascript:void(0);" onclick="$('#dropdownMenu122').text('Ms.');$('#user_title').val('<%="Ms."%>');"><%="Ms."%></a></li>
        <li role="presentation" class="dd-li">
        <a role="menuitem" tabindex="-1" href="javascript:void(0);" onclick="$('#dropdownMenu122').text('Mrs.');$('#user_title').val('<%="Mrs."%>');"><%="Mrs."%></a></li>
    <%# end %>
     </ul>
  </div>

There's a border image and a seperator image which needs to be applied to the <ul> and <li> of the <select> for <dropdown> . 有一个边框图像和一个分隔符图像需要应用于<ul><select><ul><li> <dropdown>

I am not able to trace down the issue. 我无法追查这个问题。 Probably completely confused with the number of classes and the property. 可能与类和属性的数量完全混淆。 Can someone help me hunt down the issue. 有人可以帮助我解决这个问题。

Here's the fiddle . 这是小提琴

You can try the following, 您可以尝试以下方式,

in your .ul-signup> li > a add border-bottom: 1px solid #000; 在你的.ul-signup> li > a add border-bottom: 1px solid #000;

and also add 并且还添加

#dropdownMenu1 {
    border: 1px solid #000;
}

Here is the modified fiddle 这是修改过的小提琴

And to add the border you just need to add border to the ul element. 要添加边框,您只需要为ul元素添加边框。

********* UPDATED WITH IMAGE SEPARATOR ********************* *********用图像分离器更新 *********************

I used a random line image from google because your image appeared too whitey to me. 我使用谷歌的随机线图像,因为你的图像对我来说太白了。

Check this updated fiddle 检查这个更新的小提琴

Thank you. 谢谢。

You can do this with border-bottom and border-color 您可以使用border-bottom和border-color执行此操作

Change your ul-signup>li>a to 将您的ul-signup> li> a更改为

.ul-signup> li > a { .ul-signup> li> a {

 display: block;
  background-position: 10px bottom;
  background-image: url("http://i.imgur.com/OdpE6ba.png");
  border-bottom: 1px solid;
  border-color:#C8C8C8;
  font-weight: normal;
  line-height: 1.42857143;
  color: black;
  white-space: nowrap;
}

here is a fiddle http://jsfiddle.net/qh1cuonh/2/ 这是一个小提琴http://jsfiddle.net/qh1cuonh/2/

First off, why not use Bootstrap? 首先,为什么不使用Bootstrap? http://getbootstrap.com/ http://getbootstrap.com/

Second, If you want to add in image inside a li or ul you can do this in a couple of ways, one of which is 其次,如果你想在li或ul中添加图像,你可以通过几种方式添加图像,其中之一就是

<li>
     <img src="path/to/image"></img>
<li>

Another way to accomplish this is in css add a background to the <li> and giving it an offset. 另一种实现此目的的方法是在css中为<li>添加背景并为其赋予偏移量。

Please remove 请删除

  background-position: 10px bottom;
  background-image: url("http://i.imgur.com/OdpE6ba.png");

from this css selector .ul-signup> li > a , i have replaced ur border image in css selector .dd-li because it not that much visible 从这个css选择器.ul-signup> li > a ,我已经在css选择器.dd-li替换了你的边框图像,因为它没那么多可见

updated fiddle 更新小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM