我正在尝试在我的项目导航栏中使用jQuery-UI自动完成实时搜索,但是当实时搜索出现时,它隐藏在我的导航栏后面。我使用z-index但它不再有效。我该怎么办?
这是图片:
这是我的代码:
<div class="col-sm-3 col-md-8">
<form class="navbar-form navbar-center" role="search" method="get">
<div class="input-group searchbar">
<input id="cari" type="text" class="form-control" placeholder="Aku mau belanja.." name="q">
<div class="input-group-btn">
<button id="sb" class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</form>
</div>
所以我给出了风格:
<style type="text/css">
.ui-menu .ui-menu-item-wrapper {
position: relative;
z-index: 100000;
}
.container-fluid {
position: relative;
z-index: 30;
}
</style>
但它也不起作用。我该怎么办?
修改
.ui-menu .ui-menu-item-wrapper {
position: relative;
z-index: 100000;
}
.container-fluid {
position: relative;
z-index: 30;
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>ShoppingKuy</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet" type="text/css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script
src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"
integrity="sha256-0YPKAwZP7Mp3ALMRVB2i8GXeEndvCq3eSl/WsAl1Ryk="
crossorigin="anonymous"></script>
<link href="<?php echo base_url();?>assets/css/jquery-ui.css" rel="stylesheet" type="text/css" />
</head>
<body id="myPage" data-spy="scroll" data-target=".navbar" data-offset="50">
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="<?php echo base_url(); ?>">Logo</a>
</div>
<div class="col-sm-3 col-md-8">
<form class="navbar-form navbar-center" role="search" method="get">
<div class="input-group searchbar">
<input id="cari" type="text" class="form-control" placeholder="I want to buy" name="q">
<div class="input-group-btn">
<button id="sb" class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</form>
</div>
</nav>
<script type="text/javascript">
$(document).ready(function(){
$("#cari").autocomplete({
source: "<?php echo base_url();?>core/liveSearch",
autoFocus : false,
minLength : 2
});
})
</script>
</body>
</html>