<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.social-media-icon{
display: inline-block;
}
.social-media-icon a{
text-decoration: none;
display: block;
text-indent: -9999px;
border: 2px solid #c3d4e2;
position: relative;
height: 36px;
width: 36px;
background: url(/img/social-icons.png) ;
background-repeat: no-repeat;
background-position: 50%;
}
.social-media-icon a:hover{
background-color: #c3d4e2;
}
.fb-icon a{
background-position: 0 0 ;
}
.fb-icon a:hover{
background-position: 0 -36px;
}
.x-icon a{
background-position:-36px 0 ;
}
.x-icon a:hover{
background-position: -36px -36px ;
}
.youtube-icon a{
background-position: -72px 0 ;
}
.youtube-icon a:hover{
background-position: -72px -36px ;
}
.insta-icon a{
background-position: -108px 0 ;
}
.insta-icon a:hover{
background-position: -108px -36px ;
}
</style>
</head>
<body>
<div class="social-media">
<div class="fb-icon social-media-icon icon">
<a href="">
<span class="social-text">fb</span>
</a>
</div>
<div class="x-icon social-media-icon icon">
<a href="">
<span class="social-text">x</span>
</a>
</div>
<div class="youtube-icon social-media-icon icon">
<a href="">
<span class="social-text">youtube</span>
</a>
</div>
<div class="insta-icon social-media-icon icon">
<a href="">
<span class="social-text">intergram</span>
</a>
</div>
</body>
</html>
This code snippet is for creating background images using image sprites. when hovering over the image that background image should change.
I want to center those social media icons in that div
element. I tried background-position: center center
but it didn’t work. Here I attached an output of the above code snippet. That isn’t centered properly. What can I do to center all images in each div elements
This is the main image