背景图像在下拉列表中右对齐文本

时间:2017-06-30 10:43:49

标签: html css drop-down-menu html-lists nowrap

基本上,我想要如下所示的结果,箭头与下拉列表中文本的右侧对齐。

enter image description here

但我的箭头与最长的文字对齐到底部:(

enter image description here

请问我的解释是否不够清楚,希望你们中的一些人可以提供一些建议。谢谢!

仅供参考:我使用white-space:nowrap;来阻止换行。

ul { list-style-type: none; margin:0; padding: 0; }
ul.detailsec { float:left; width:auto; margin:0; padding:0; list-style-type:none;}
ul.detailsec > li.maindetail { float:left; display:inline; position:relative; padding-left: 10px; }
ul.detailsec > li input.button { background-color: #39007d; width: 103px; height: 30px; border: 0; color: #fff; cursor: pointer; font-size:12px;}
ul.detailsec > li input.button:hover{ background-color: #313131;}
ul.detailsec > li.maindetail:hover ul { visibility: visible; opacity: 1; transition-delay: 0s, 0s; }
ul.detailsec li.maindetail ul { position:absolute; float:left; height:0; padding-top:1px; margin:0; right:0; visibility: hidden; opacity: 0; transition-property: opacity, visibility transition-duration: .4s, 0s; transition-delay: 0s, .4s; }
ul.detailsec ul li.subdetail a{ background-color:#ededed; border-bottom:1px solid #d9d8d8; padding: 12px; display: block; white-space:nowrap; color: #5f5d5d; font-size: 13px; font-weight: normal; font-weight:bold; text-decoration: none;  }
ul.detailsec ul li.firstrow a { padding: 8px 12px !important;}
ul.detailsec ul li.lastrow a { border-bottom:2px solid #b3b0b0 !important; }
ul.detailsec ul li.smalltxt a{ font-size: 11px !important; color:#5f5d5d !important; border:none !important;}
ul.detailsec ul li.subdetail a:hover { color:#36145f; font-weight:bold; text-decoration: none; }

.arrow_menunav{ background: url('https://image.ibb.co/krCosk/arrow_menunav.png'); width:18px; height: 11px; float:right;}
<ul class="detailsec">
  <li class="maindetail"><input class="search" name="search" type="text" value="" placeholder="Search"></li>
  <li class="maindetail"><input border="0" title="Login" type="submit" value="LOGIN" class="button">
    <ul>
      <li class="subdetail"><a href="">Individuals<div class="arrow_menunav"></div></a></li>
      <li class="subdetail"><a href="">Reg Type (ROB/ ROC/ UENO)<div class="arrow_menunav"></div></a></li>
      <li class="subdetail lastrow"><a href="">Reg Type (Others)<div class="arrow_menunav"></div></a></li>
    </ul>
  </li>
</ul>

1 个答案:

答案 0 :(得分:1)

如果你没有使用额外的元素,这会更容易,但只是将背景应用于function CustInfo() { var vm = this; vm = { "custId": "", "custTitle": "", "custName": "" }; return vm; } 元素本身......

a
ul { list-style-type: none; margin:0; padding: 0; }
ul.detailsec { float:left; width:auto; margin:0; padding:0; list-style-type:none;}
ul.detailsec > li.maindetail { float:left; display:inline; position:relative; padding-left: 10px; }
ul.detailsec > li input.button { background-color: #39007d; width: 103px; height: 30px; border: 0; color: #fff; cursor: pointer; font-size:12px;}
ul.detailsec > li input.button:hover{ background-color: #313131;}
ul.detailsec > li.maindetail:hover ul { visibility: visible; opacity: 1; transition-delay: 0s, 0s; }
ul.detailsec li.maindetail ul { position:absolute; float:left; height:0; padding-top:1px; margin:0; right:0; visibility: hidden; opacity: 0; transition-property: opacity, visibility transition-duration: .4s, 0s; transition-delay: 0s, .4s; }
ul.detailsec ul li.subdetail a{ background-color:; border-bottom:1px solid #d9d8d8; padding: 12px 37px 12px 12px; display: block; white-space:nowrap; color: #5f5d5d; font-size: 13px; font-weight: normal; font-weight:bold; text-decoration: none; background: #ededed url('https://image.ibb.co/krCosk/arrow_menunav.png') no-repeat top 50% right 10px; }
ul.detailsec ul li.firstrow a { padding: 8px 12px !important;}
ul.detailsec ul li.lastrow a { border-bottom:2px solid #b3b0b0 !important; }
ul.detailsec ul li.smalltxt a{ font-size: 11px !important; color:#5f5d5d !important; border:none !important;}
ul.detailsec ul li.subdetail a:hover { color:#36145f; font-weight:bold; text-decoration: none; }