我有一個自動建議下拉菜單的輸入。我遇到的問題是頁面縮放時,ul會從輸入字段略微移動,因此它不再與輸入字段平行或齊平。有沒有更好的方法可以做到這一點?我在這裏有代碼,我也做了一個jsfiddle來演示。當頁面被縮放時,ul下拉菜單略有變化
.suggestionsBox
{
position:absolute;
top:24px;
left:37px;
width:200px;
padding:0px;
background-color:fff;
}
.suggestionList
{
margin:0px;
padding:0px;
}
.suggestionList ul li
{
list-style:none;
margin: 0px;
padding:6px;
}
.suggestionList ul li:hover
{
background-color: #DAD6D6;
color:#000;
}
ul
{
font-size:12px;
padding:0;
margin:0;
border:1px solid grey;
border-top:none;
}
.load
{
background-position:right;
background-repeat:no-repeat;
}
table
{
border-collapse:collapse;
}
#suggest
{
position:relative;
}
#email
{
outline: none;
width:200;color:grey;
border:1px solid grey;
padding:2;
}
<div id = "suggest">
<div>
<table>
<td>email:</td>
<td><input type = "text" id = "email" autocomplete = "off" placeholder = "type something then zoom" /></td>
</table>
<div class="suggestionsBox" id = "suggestions" style = "display: none;">
<div class="suggestionList" id = "suggestionsList">
</div></div></div></div>
和JavaScript:
$('#email').bind('keyup',function() {
if($('#email').val().length >0) {
$('#suggestions').show();
$('#suggestionsList').html("<ul><li>now zoom in or out</li><ul>");
}else $('#suggestions').hide();
});
難道你不能調整位置http://jsfiddle.net/kevinPHPkevin/sSXje/1/ – Vector 2013-04-07 16:54:58