Reputation: 133
I'm trying to get a round button which has a an outline in the same color but that doesn't seem to be possible. The outline always ends up squared. Is there a method to achieve that with a or does it maybe only work with a ?
button {
width: 40px;
height: 40px;
border: none;
border-radius: 40px;
cursor: pointer;
background-color: black;
display: inherit;
outline: 5px solid black;
outline-offset: 5px;
}
<button></button>
I have added a picture since this only seems to happen on Safari...Screenshot from Safari snippet
I need it to work in all browsers especially on mobile though.
Upvotes: 12
Views: 13307
Reputation: 255
Workaround is no longer needed.
They finally added it in Safari 16.4:
https://developer.apple.com/documentation/safari-release-notes/safari-16_4-release-notes
Upvotes: 5
Reputation: 7448
For example instead of outline: 2px solid gray
can be used box-shadow: 0 0 0 2px gray
. Box-shadow + border-radius works OK in silly Safari. Fixing with ::after is too complicated with in about 10 additional CSS properties.
Upvotes: 8
Reputation: 65
Safari fixed this bug on Safari Technology Preview 157. Source: https://webkit.org/blog/13575/release-notes-for-safari-technology-preview-157/
Upvotes: 5
Reputation: 1002
You can use this "hack".
INFO: In Brave Browser we got a square too with your snippet;
button {
position: relative;
width: 40px;
height: 40px;
border: none;
border-radius: 40px;
cursor: pointer;
background-color: black;
display: inherit;
margin:10px 2px;
}
button::after {
position: absolute;
top: -10px;
content: '';
left: -10px;
width: 50px;
height: 50px;
border: 5px solid black;
border-radius: 40px;
background-color: transparent;
display: inherit;
}
<button></button>
Upvotes: 5
Reputation: 36
According to your question and code snippet that you have provided. From my browser when I ran both the button and the outline was Circle.
I would suggest you to clear your cache and run the code again OR try changing the browser.
Or please update your question with a screenshot as well, so that we can understand better.
Upvotes: -3