I currently have images set up as checkboxes that display a yellow border upon clicking with a transition effect. However, the transition of the border causes the images to shake and shutter slightly due to margin adjustments.
To resolve this issue, I tried setting a default margin of 3px which gets overridden when the border appears (also 3px). This led to an awkward shaking effect as the border grows during the transition.
My goal now is to have the border instantly appear as 3px upon clicking without causing any immediate visual disturbance. Here is my current CSS code:
Unfortunately, I'm unable to provide the full CSS code here due to restrictions, but I have included a snippet below:
img{
width: 100%;
max-width: 380px;
border: 3px solid rgba(255,0,0,0);
background-color: black;
height: 100%;
max-height: 250px;
margin: 3px;
border-radius: 15px;
transition: opacity 2s ease, border 1s ease;
opacity: 0.5;
}
<img src="http://placehold.it/380x250" />