Border radius still square internally

Border radius still square internally



I have a page that lists some predefined avatars that users can selected, as seen here -



enter image description here



These are defined as follows -


<span class="avatar-box">
<img src="..." class="avatar" style="width: 100px; height: 100px;" />
</span>

.avatar-box
width: 120px;
height: 120px;
text-align: center;
vertical-align: middle;


.avatar
border-radius: 50%;
margin: 10px;



When I click on an avatar, jQuery adds a class of "selected" to "avatar" -


.selected
border: 10px solid #40ac2b !important;



However, when this happens, the following happens on Chrome -



enter image description here



As you can see, while the avatar remains round, the border added is still square. This behaviour does not happen in Firefox, only Chrome.



What can I do to ensure the border remains round, like the avatar itself?





Can't you add border-radius: 50%; to .selected as well?
– Barmar
Aug 30 at 2:10



border-radius: 50%;


.selected





it adds selected on avatar or on avatar-box?
– Deepak Sharma
Aug 30 at 2:41


selected


avatar


avatar-box





@Barmar doing this seems to make no change to the outcome
– Paul McLean
Aug 30 at 2:53





@DeepakSharma it adds selected to avatar, not avatar-box
– Paul McLean
Aug 30 at 2:53





"the border added is still square." I want to clarify this. Isn't your original image square in the first place?
– reiallenramos
Aug 30 at 3:18




1 Answer
1



Set default border with transparent color, and after hover/active border color changed, because border size effect the size i.e height and width.



Have a look below example.




body
background:#ccc;


.avatar-box
width: 120px;
height: 120px;
text-align: center;
vertical-align: middle;
margin: 10px;


.avatar
border-radius: 50%;
border:10px solid transparent;


.avatar:hover
border:10px solid #ff0000;


<span class="avatar-box">
<img src="https://i.stack.imgur.com/CpldL.png?s=328&g=1" class="avatar" style="width: 100px; height: 100px;" />
</span>





Please explain what you changed and, more important, why.
– Barmar
Aug 30 at 15:09





i set default border with transparent color, and after hover/active border color changed, because border size effect the size i.e height and width.
– Nikesh Kumar
Aug 31 at 6:36





The explanation should be in the answer, not a comment.
– Barmar
Aug 31 at 7:06





thanks got your points
– Nikesh Kumar
Aug 31 at 8:26



Required, but never shown



Required, but never shown






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ

Node.js puppeteer - Use values from array in a loop to cycle through pages