I want to create a navbar with HTML and CSS and I want when I hover my mouse cursor over each item , a little line would appear bellow the items (like border-bottom) with a 0.2s transition. and I want the line appears from right to left I searched and I found that I should use this code:
transition : width time ;
like
transition : width 0.2s ;
but when I use this code the "width" is not working and its undefined. can u help me with it ?
body
{
background-color: gray;
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
}
ul
{
list-style-type: none;
margin: 0;
padding:0;
overflow: hidden;
background-color: #333;
border-radius: 50px;
width: 90%;
}
li
{
float: left;
transition:width 0.2s;
}
li a
{
display: block;
text-decoration: none;
color: rgb(255, 255, 255);
text-align: center;
padding: 15px 20px;
}
.searchbtn
{
float: right;
}
li:hover
{
background-color: rgb(43, 43, 43) ;
border-bottom: 3px solid white;
}
<!DOCTYPE html>
<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="style.css">
<script src="script.js"></script>
<title>Title</title>
<link rel="icon" type="icon/x-type" href="IMG/fav.png">
</head>
<body>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Support</a></li>
<li class="searchbtn"><a href="#">Search</a></li>
</ul>
</body>
</html>