I got a weird behavior when working with transform
in CSS3.
Here is my code:
*, *:before, *:after {
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
}
.btn_exchange a {
position: relative;
text-decoration: none;
display: block;
width: 150px;
float: left;
color: #ffffff;
font-size: 14px;
background: #0ea2d3;
box-shadow: 0 3px 0 0 rgba(7, 154, 190, 0.75);
text-align: center;
font-weight: bold;
}
@keyframes pulse {
0% {
transform: scale(1);
}
50% {
transform: scale(1.05);
}
100% {
transform: scale(1);
}
}
@-webkit-keyframes pulse {
0% {
transform: scale(1);
}
50% {
transform: scale(1.05);
}
100% {
transform: scale(1);
}
}
a.abc {
z-index: 0;
-webkit-animation: pulse 1s linear 0s infinite alternate;
animation: pulse 1s linear infinite;
}
#box_avatar {
position: relative;
margin: 0 auto;
-webkit-border-radius: 62.5px;
-moz-border-radius: 62.5px;
-ms-border-radius: 62.5px;
-o-border-radius: 62.5px;
border-radius: 62.5px;
width: 125px;
height: 125px;
border: 2px solid #ccc;
display: block;
overflow: hidden;
}
#img_avatar {
width: 125px;
height: 125px;
cursor: pointer;
border-radius: 62.5px;
}
#bg_gray {
background: #4c4747;
width: 100%;
position: absolute;
bottom: 0;
padding: 8px 0 10px 0;
opacity: 0.8;
}
#bg_gray img {
display: block;
width: 20px;
margin: 0 auto;
}
<div class="btn_exchange fl bad">
<a class="button abc" href="#">Button</a>
</div>
<div id="box_avatar">
<img id="img_avatar" src="http://i.imgur.com/O29DJOZ.jpg" alt="avatar" />
<div id="bg_gray">
<img src="http://i.imgur.com/m5qIRID.png" alt="btn_camera" />
</div>
</div>
<div class="btn_exchange fl good">
<a class="button abc" href="#">Button</a>
</div>
The problem happens when I use the .bad
div (remove .good
div) then the gray background which contains the camera-icon does not lay inside the circle image.
If I remove the animation transform
in CSS, the button won't pulse anymore but the gray background will be inside circle image.
Anyone know what it is and how to solve it?