I want to disable the click event for border fields. Why are borders clickable and how can I fix it?
.circle {
border-radius: 100px;
}
span {
display: block;
background: #000;
width: 200px;
height: 400px;
border-radius: 100px;
}
Thanks.
You can solve this undesired effect using CSS, because the user is not clicking in the span
element, but in a
(that doesn't have border-radius
).
To solve this, just remove the span
element and it's styles, and style the a
element instead:
a {
display:block;
background:#000;
width:200px;
height:400px;
border-radius:100px;
}
This is not possible, at least without a lot of very complicated maths to determine whether the click was inside the element or beyond the curves.
Remember elements have box models; so even if you curve them, they are still viewed as boxes by the browser and represented as such in the DOM. If they weren't, you'd have nearby elements seeping into the space vacated by the border radius, which doesn't happen.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.