Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML button becomes square after background color is set on Chrome for Mac

on Chrome for Mac, why the buttons become square after background color is set (normally it is rounded)?

<html>
<body>
  <input type="button" id="bt1" value="Click me!" onmouseover="this.style.backgroundColor='red;'" onmouseout="this.style.backgroundColor='transparent';">
</body>
</html>

The web page when the mouse has not been over the button:

enter image description here

The web page when the mouse is over the button:

enter image description here

The web page after the mouse was over the button:

enter image description here

How to set the background without making the button square?

Thanks.

like image 780
An Cong Tran Avatar asked Mar 21 '23 16:03

An Cong Tran


1 Answers

WebKit/Blink draws buttons as "-webkit-appearance:push-button", which draws buttons with the native API (Cocoa in this case). However the native API doesn't support arbitrary background colors. So WebKit/Blink automatically removes "-webkit-appearance:push-button" internally and falls back to poor CSS drawing if a web author specifies some CSS properties such as background-color.

You can't change background color with the native button appearance.

like image 65
int32_t Avatar answered Apr 06 '23 16:04

int32_t