【发布时间】:2017-03-29 21:49:13
【问题描述】:
我正在使用 ajax 和 jquery UI 在输入字段中进行搜索和选择。如何设置下拉内容的样式以不显示<ul> 子弹并且还有白色背景?我一直在尝试使用 ID 来定位搜索字段,但它会更改输入框而不是下拉框。我在这里附上截图。
【问题讨论】:
标签: javascript jquery css ajax
我正在使用 ajax 和 jquery UI 在输入字段中进行搜索和选择。如何设置下拉内容的样式以不显示<ul> 子弹并且还有白色背景?我一直在尝试使用 ID 来定位搜索字段,但它会更改输入框而不是下拉框。我在这里附上截图。
【问题讨论】:
标签: javascript jquery css ajax
一个CSS解决方案
将you li标签上的列表样式类型更改为none。并为您的 ul 标签添加白色背景
li {
list-style-type: none
}
ul {
background: white;
}
<ul>
<li>Option</li>
</ul
【讨论】:
如果像我这样的人正在为 Ajax 调用的 jQuery UI 样式而苦苦挣扎,这里是我从博客复制粘贴的引导代码,它非常适合我。
.ui-autocomplete {
position: absolute;
top: 100%;
left: 0;
z-index: 1000;
float: left;
display: none;
min-width: 160px;
padding: 4px 0;
margin: 0 0 10px 25px;
list-style: none;
background-color: #ffffff;
border-color: #ccc;
border-color: rgba(0, 0, 0, 0.2);
border-style: solid;
border-width: 1px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
-webkit-background-clip: padding-box;
-moz-background-clip: padding;
background-clip: padding-box;
*border-right-width: 2px;
*border-bottom-width: 2px;
}
.ui-menu-item > a.ui-corner-all {
display: block;
padding: 3px 15px;
clear: both;
font-weight: normal;
line-height: 18px;
color: #555555;
white-space: nowrap;
text-decoration: none;
}
.ui-state-hover, .ui-state-active {
color: #ffffff;
text-decoration: none;
background-color: #0088cc;
border-radius: 0px;
-webkit-border-radius: 0px;
-moz-border-radius: 0px;
background-image: none;
}
【讨论】: