I am currently working on developing my personal news website called News Pews. This is my third project, and I have encountered an issue that was not present in my previous projects.
The problem arises when I apply position: fixed; top:0;
to the header containing a search button that opens a modal. The modal becomes unreachable due to this styling.
Below is the snippet of code causing the issue:
#search_btn {
background-color: white;
border-radius: 7px;
border: none;
width: 35px;
height: 35px;
justify-content: center;
align-items: center;
display: flex;
transition: all 0.5s ease;
}
header {
position: fixed;
top: 0;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b3d1dcdcc7c0c7c1d2c3f3869d809d80">[email protected]</a>/dist/css/bootstrap.rtl.min.css" integrity="sha384-dpuaG1suU0eT09tx5plTaGMLBsfDLzUCCUXOY2j/LSvXYuG6Bqs43ALlhIqAJVRb" crossorigin="anonymous">
<link rel="stylesheet" href="css/stayle.css">
<title>Document"</title>
</head>
<body>
<header class="bg-danger w-100">
<button type="button" class="mx-2 me-md-5 ms-md-3" data-bs-toggle="modal" data-bs-target="#search_modal" id="search_btn">جستجو</button>
<div class="modal fade " id="search_modal">
<div class="modal-dialog modal-dialog-centered ">
<div class="modal-content ">
<div class="modal-header">
<h4 class="">برای جستجو تایپ کنید:</h4>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<form class="d-flex" role="search">
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success" type="submit">Search</button>
</form>
</div>
</div>
</div>
</div>
</header>
</body>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9dfff2f2e9eee9effceddda8b3aeb3ae">[email protected]</a>/dist/js/bootstrap.bundle.min.js"></script>
</html>