search

Home  >  Q&A  >  body text

How to get a circular outline on a circular <button> using CSS in Safari

I'm trying to get a round button with the same color outline, but it doesn't seem possible. The outline always ends up being square. Is there a way to achieve this with a , or maybe it can only be achieved 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've added a picture because this only seems to happen on Safari...Screenshot from Safari snippet

I need it to work in all browsers, especially on mobile devices.

P粉066725148P粉066725148456 days ago1069

reply all(2)I'll reply

  • P粉434996845

    P粉4349968452023-10-27 00:44:59

    Safari This bug is fixed in Safari Technical Preview 157. Source: https://webkit.org/blog/13575/release-notes-for-safari-technology-preview-157/

    reply
    0
  • P粉805535434

    P粉8055354342023-10-27 00:14:27

    You can use this "hack".

    Information: In the Brave browser, your snippet also appears as a square;

    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;
    }

    reply
    0
  • Cancelreply