enter image description hereI am trying to make a social media icon project. In this project, I'm trying that if any user clicks or over any social media icon, above the icon there will be a content text which includes the social icon's name. I am doing in using tag's (::before) element but I'm trying my best but failed to center the content text to its background color. Please help me to center the text of its background color.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background-color: rgb(235, 219, 222);
font-family: Arial, Helvetica, sans-serif;
}
.icons {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.icons ul {
display: flex;
list-style-type: none;
}
.icons ul li {
margin: 30px;
}
.icons ul a {
text-decoration: none;
color: black;
font-size: 22px;
width: 60px;
height: 60px;
background-color: white;
border-radius: 50%;
display: inline-block;
text-align: center;
line-height: 60px;
position: relative;
}
.icons ul a::before {
content: "Facebook";
position: absolute;
width: 83px;
height: 31px;
background-color: black;
top: -52px;
left: -10px;
color: white;
font-size: 18px;
text-align: center;
font-weight: 500;
font-family: Arial, Helvetica, sans-serif;
border-radius: 5px;
}
<!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">
<title>Document</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" integrity="sha512-KfkfwYDsLkIlwQp6LFnl8zNdLGxu9YAA1QvwINks4PhcElQSvqcyVLLD9aMhXd13uQjoXtEKNosOWaZqXgel0g==" crossorigin="anonymous" referrerpolicy="no-referrer"
/>
</head>
<body>
<div class="icons">
<ul>
<li><a href="#"><i class="fa-brands fa-facebook-f"></i></a></li>
<li><a href="#"><i class="fa-brands fa-instagram"></i></a></li>
<li><a href="#"><i class="fa-brands fa-linkedin-in"></i></a></li>
<li><a href="#"><i class="fa-brands fa-tiktok"></i></a></li>
<li><a href="#"><i class="fa-brands fa-bilibili"></i></a></li>
<li><a href="#"><i class="fa-brands fa-paypal"></i></a></li>
</ul>
</div>
</body>
</html>