gpt4 book ai didi

javascript - 如何自定义警告框的 css 字段?

转载 作者:可可西里 更新时间:2023-11-01 13:35:38 24 4
gpt4 key购买 nike

我的要求是使用 css 属性自定义警告框。目前我正在通过以下代码实现类似的东西:

JQUERY:

$('<div class="alertMessage">Error first</div>')
.insertAfter($('#componentName'))
.fadeIn('fast')
.animate({opacity: 1.0}, 2200)
.fadeOut('fast', function() {
$(this).remove();
});

CSS:

.alertMessage {
width: 95%;
margin: 1em 0;
padding: .5em;

background-image: -ms-radial-gradient(left top, circle farthest-corner, #F07E1A 0%, #F58CCB 100%);
background-image: -moz-radial-gradient(left top, circle farthest-corner, #F07E1A 0%, #F58CCB 100%);
background-image: -o-radial-gradient(left top, circle farthest-corner, #F07E1A 0%, #F58CCB 100%);
background-image: -webkit-gradient(radial, left top, 0, left top, 1012, color-stop(0, #F07E1A), color-stop(1, #F58CCB));
background-image: -webkit-radial-gradient(left top, circle farthest-corner, #F07E1A 0%, #F58CCB 100%);
background-image: radial-gradient(circle farthest-corner at left top, #F07E1A 0%, #F58CCB 100%);

text-align: center;
border: 3px solid white;
color: white;
font-weight: bold;
border-radius:4px;
display: none;
}

上面的代码会在几秒后淡入淡出。此外,淡入和淡出将发生在我在代码中提到的组件旁边

insertAfter($('#componentName'))

我的要求是:

  1. 警告消息应该出现在窗口的中央。就像普通的警告框一样
  2. 警报消息应该有一个确定按钮。就像普通的警告框一样。

我是否只能通过向 div 添加“确定”按钮并为“确定”按钮添加行为来实现此目的?或者有什么方法可以扩展通用警告框行为并使用我上面提到的 css 属性对其进行自定义?如果是,如何实现?

最佳答案

您需要自己实现外观和行为,标准警告框不可自定义。

您已经在使用 jQuery 的替代方法是使用 jQueryUI 提供的功能.

关于javascript - 如何自定义警告框的 css 字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17273228/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com