I encountered an unusual issue while experimenting with the transform
property in CSS3.
Below is the code I used:
*, *: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 issue arises when using the .bad
div (eliminating the .good
div), causing the gray background with the camera icon to not fit within the circular image.
If I remove the transform
animation in CSS, the button will no longer pulse but the gray background will align correctly within the circular image.
Does anyone have insights on this and how to resolve it?