How to style default confirm box with only css?

2019-01-03 11:04发布

I would like to style standard window.confirm without using any additional JavaScript code, only with CSS. Is it even possible? And if it is, how can I do it?

标签: css confirm
3条回答
何必那么认真
2楼-- · 2019-01-03 11:28

confirm(); alerts cannot be styled, they are generic to the browser. If you want to style an alert, try alternatives such as boxy, or the jQuery dialog box.

Here is a tutorial about how a custom confirm alert can be created in jQuery and styled with CSS.

查看更多
乱世女痞
3楼-- · 2019-01-03 11:31

This is a very old question. But I felt the need to pass this info here. I noticed that you can "style" the confirm with special characters, such as \n, \t, \r, ... so on.

查看更多
祖国的老花朵
4楼-- · 2019-01-03 11:44

It is not possible. This window is displayed by the browser using the platform's UI kit. It's not in the DOM, not visible from the CSS or Javascript, there's nothing you can do.

However, some very simple jQuery code can do the trick. How about $('a').confirm(); ?

查看更多
登录 后发表回答