My search form includes side filters to help users narrow down their search, with the results appearing on the right.
This is just a basic example, as my actual setup involves more filters. However, there is one issue â users have to scroll down the page in order to reach the search button.
Is there a way to keep the search button fixed at the top of the filter-cn
section so that it remains visible as users scroll through the filters?
.my-container {
padding: 20px;
}
.filter-cn {
padding: 30px;
border: 1px solid #e8e8e8;
}
.fix-on-top {
/* I want this button to appear on top of filter when user scrolls */
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-light bg-dark">
<a class="navbar-brand" href="#">Navbar</a>
</nav>
<div class="container my-container">
<div class="row">
<div class="col-4 filter-cn">
<form>
<div class="fix-on-top">
<button type="button" class="btn btn-primary btn-block">Search</button>
</div>
<div class="form-group">
<label>Keyword</label>
<input type="text" class="form-control form-control-lg" id="keyword" placeholder="Looking for...">
<label>Make</label>
<input type="text" class="form-control form-control-lg" id="Make" placeholder="Make...">
<label>Model</label>
<input type="text" class="form-control form-control-lg" id="Model" placeholder="model...">
</div>
</form>
</div>
<div class="col-8">
second colum for displaying search result on the side
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>
I am hoping to achieve a layout similar to this when users scroll: