I'm trying to vertically center a floating link with a background image next to text with dynamic height.
Here's what I have:
<!DOCTYPE html> <html> <head> <title>test</title> <link rel="stylesheet" href="style.css" /> </head> <body> <div class="container"> <a class="img"></a> <div class="text"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </div> </div> </body> </html>
CSS file is:
.container{
margin:auto;
width:300px;
}
.text{
margin-right:50px;
}
.img{
display:block;
background-image:url(img.png);
background-repeat:no-repeat;
background-position:center;
height: 47px;
width: 47px;
float:right;
}
All I need is a way to get the link vertically centered without knowing the height of the container (the text is dynamic).
Thank you.

New Topic/Question
Reply



MultiQuote





|