I have a structure as follows:
html {
background-color: rgba(0, 0, 0, 0.75);
}
.container {
margin: 10% auto;
text-align: center;
}
div > span {
display: inline-block;
}
.horizontal {
display: inline-block;
position: relative;
top: .1em;
width: 15%;
}
.bubble {
display: inline-block;
padding: 0.5em;
background: url(http://imgh.us/Service_bubble.svg) no-repeat;
background-size: contain;
transition: all 0.3s ease-in-out;
}
.bubble:hover {
transform: scale(2) rotate(-90deg);
}
<!DOCTYPE html>
<html>
<head>
<link href="//netdna.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<meta charset="utf-8">
</head>
<body>
<div class="container">
<div class="bubble">
<span class="fa fa-inverse fa-google fa-lg"></span>
</div>
<hr class="horizontal" />
<div class="bubble">
<span class="fa fa-inverse fa-facebook fa-lg"></span>
</div>
<hr class="horizontal" />
<div class="bubble">
<span class="fa fa-inverse fa-twitter fa-lg"></span>
</div>
<hr class="horizontal" />
<div class="bubble">
<span class="fa fa-inverse fa-github fa-lg"></span>
</div>
</div>
</body>
</html>
As you can see with the snippet, when you hover over any of the icon, the bubble wrapping any icon scales up, and rotates to the left by 90 deg. (which is expected). Now, I'd like to not propagate the rotation to the children (div > span
). They should scale up, but the rotation should not occur.
Also, if possible, I'd like to displace the hr
s as well, when an icon is hovered over, and it zooms. The hr
s should shift accordingly, leaving a little margin around the bubbles.
I've tried setting the following property:
div > span:hover {
transform: scale(2);
}
but it scales up the icon by 4x when hovering, and the rotation still occurs.
Any ideas? I'd like to rely only on CSS, and would prefer not to involve JavaScript here.