I am wanting to make a hover line that appears above my text when I hover my mouse towards the text. However, I want the hover line to be exactly the same length as each of my texts. In case you're wondering, I am wanting to put this effect to my navigation part of HTML.
My HTML (in case you need it)
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Satisfy|Tajawal&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous">
<script src="myscripts.js">
</script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="script.js"></script>
<link rel="stylesheet" type="text/css" href="css/styles.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js" type="text/javascript"></script>
<script type="script/script.js">
</script>
<title>Felicity Hayes Official Website</title>
</head>
<body>
<h1>Felicity Hayes</h1>
<!--- Navigation -->
<div class="navigation">
<nav>
<ul>
<li><a href="#">Art of Gifting</a></li>
<li><a href="#">Fashion</a></li>
<li><a href="#">Fragrances</a></li>
<li><a href="#">Bridal</a></li>
<li><a href="#">The House</a></li>
<li><a href="#">Services</a></li>
</ul>
</nav>
</div>
<div class="row">
<div class="column">
<img src="img/bag3.jpg">
<img src="img/bag2.jpg">
<img src="img/bag1.jpg">
<img src="img/bag4.jpg">
<img src="img/bag5.jpg">
</div>
</div>
<div class="textbox-1">
<p> CAROLINA HERRERA NEW YORK <br> RESORT 2020 </br> </p>
<button> Discover Now </button>
</div>
<div class="textbox-2">
<p> CAROLINA HERRERA NEW YORK <br> BAD BOY </br> </p>
<button> Discover Now </button>
</div>
<div class="textbox-3">
<p> CH CAROLINA HERRERA <br> RESORT </br> </p>
<button> Discover More </button>
</div>
<div class= "white-border">
<p> 212 CAROLINA HERRERA <br> 212 VIP </br> </p>
<button> Discover More </button>
<div class="row">
<div class="column">
<img src="img/girl1.jpg">
<img src="img/perfume1.jpg">
<img src="img/perfume2.jpg">
<div class="navButton" id="previous">❮</div>
<div class="navButton" id="next">❯</div>
</body>
<footer>
<button> Sign up to get updates </button>
<a class="facebook" href="#"><i class="fab fa-facebook-f"></i></a>
<a class="instagram" href="#"><i class="fab fa-instagram"></i></a>
<a class="pinterest" href="#"><i class="fab fa-pinterest"></i></a>
<a class="twitter" href="#"><i class="fab fa-twitter"></i></a>
<a class="youtube" href="#"><i class="fab fa-youtube"></i></a>
</footer>
</html>
My CSS:
h1 {
font-family: 'Satisfy', cursive;
font-size: 70px;
text-align: center;
}
.navigation ul{
font-family: 'Tajawal', sans-serif;
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
text-align: center;
}
.navigation li{
display: inline-block;
float: left;
padding: 40px 50px;
text-align: center;
margin-left: 70px;
padding-top: 25px;
}
.navigation a {
color: #444;
text-decoration: none;
text-transform: uppercase;
font-size: 14px;
}
.navigation a:hover{
color: pink;
}
.navigation a::before {
content: '';
display: block;
height: 5px;
width: 100%;
background-color: pink;
position: absolute;
top: 200px;
width: 0%;
transition: all ease-in-out 250ms;
}
.navigation a:hover::before{
width: 5%;
}