Is there a way to create a navigation bar that adds a border upon hovering without the text shifting every time the border is added or removed?
function navigateToHomePage(){
window.location.replace("...");
};
$(document).ready(function(){
$(".navBar").mouseenter(function() {
$(this).css("border","2px solid black");
}).mouseleave(function() {
$(this).css("border","none");
});
})
.navBar{
display: flex;
position: sticky;
top:0;
padding: 20px;
border: none;
width: 100%;
justify-content: center;
background-color: gainsboro;
z-index: 2;
}
#Title{
color: black;
font-family: monospace;
}
<html lang="en">
<head>
<meta charset="UTF-8>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="Help.css">
<title>Help</title>
</head>
<body>
<div class="navBar" onclick="navigateToHomePage()">
<div>
<h1 id="Title">ExploreRandomSite</h1>
</div>
</div>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="Help.js"></script>
</body>
</html>