我在按钮上设置了一个focus-visible
状态。该按钮的边框半径为 4px,并且焦点状态添加了一个带有边框半径的盒子阴影。但是,当我点击按钮时,外边框的半径不是 4px。我怎样才能让那些外边界角的半径为 4px,就像按钮一样?
*这些按钮只能通过键盘导航。单击它们不会提供焦点状态。
/* Roboto Font */
@import url("https://fonts.googleapis.com/css?family=Roboto:100,100i,300,300i,400,400i,500,500i,700,700i,900,900i&display=swap");
/*resets*/
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html, body {
font-family: "Roboto", sans-serif;
font-size: 16px;
}
p {
font-size: 1.25rem;
line-height: 2rem;
}
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
flex-direction: column;
}
button {
margin: 1rem;
}
.btn {
background: transparent;
border: 0;
font-size: 1.25rem;
border-radius: 4px;
font-weight: 700;
box-shadow: 0px 12px 30px rgba(0, 0, 0, 0.12);
transition: all 0.2s;
cursor: pointer;
}
.btn--small {
padding: 0.5rem 1rem;
}
.btn--medium {
padding: 1rem 2rem;
}
.btn--large {
padding: 1.5rem 3rem;
}
.btn--standard {
background: #005FEC;
color: #ffffff;
}
.btn:focus-visible {
box-shadow: 0 0 0 6px #ffffff, 0 0 0 8px #005FEC;
outline: none;
border-radius: 4px;
}
<div class="container">
<button type="button" id="submit" class="btn btn--small btn--standard">Submit</button>
<button type="button" id="submit" class="btn btn--medium btn--standard">Submit</button>
<button type="button" id="submit" class="btn btn--large btn--standard">Submit</button>
</div>