简体   繁体   English

有谁知道如何用css修改警报框,或者我怎样才能创建自己的警报框

[英]Does anyone know how can i modify alert box with css, or how can i made my own

Just don't suggest me jquery ui modal because i don't know how to modify and implement that thing! 只是不建议我jquery ui模态因为我不知道如何修改和实现那个东西! Alert box work perfect but it's little ugly, i want to style it and i know that is not maybe possible because it's system tool..i need help..that modal box need to be opened when form was submitted, she need to contain message like "your message has been sent!"..Thank you brothers 警报框工作完美,但它有点难看,我想要它的风格,我知道这可能是不可能的,因为它的系统工具..我需要帮助..当提交表单时需要打开模态框,她需要包含消息喜欢“你的消息已被发送!”..谢谢各位兄弟

Code: 码:

echo '
              <!-- Poruka o NEuspiješnosti slanja -->
              <script type="text/javascript">

              alert("Greška!\nMolimo Vas ispravno popunite obrazac.");

              </script>
              <!-- Kraj -->'; } // Kraj.

You can use HTML Dialog element (www.w3.org) , HTML Dialog element (html5rocks) . 您可以使用HTML Dialog元素(www.w3.org)HTML Dialog元素(html5rocks) You can style it with css, although it's not so widely supported now 您可以使用css对其进行样式设置,尽管它现在还没有得到广泛支持

Simple Answer. 简单的答案。 No, You can't 不,你不能

Because Alertbox is system object, You cannot modify it with CSS or javascript. 由于Alertbox是系统对象,因此无法使用CSS或javascript对其进行修改。

The only way to do is, Use Jquery UI Dialog as you mentioned in your question. 唯一的方法是使用您在问题中提到的使用Jquery UI对话框

somthing like this should work 这样的事情应该有效

$(document).ready(function()
{
      $('#form').submit(function(e)
       {
           e.preventDefault();
            modal();
        });
    $('.close').click(function()
      {
                          $('#alertBox').fadeOut()
       });
 });
function modal()
{
    $('#alertBox').fadeIn();
}

HTML HTML

<div id="alertBox">
    <div class="inner">
        <div class="msg">your message has been sent!</div>
        <div class="close">close</div>
    </div>
</div>
<form id="form" method="post" action="">
    <input type="submit"/>
</form>

CSS CSS

#alertBox{
    position:fixed;
    top:50%;
    left:50%;
    width:400px;
    height:200px;
    margin-left:-200px;
    margin-top:-200px;
    border:2px solid #ccc;
    background:#fafafa;
    display:none;
    font-size:18px;
    text-align:center;

}
.close{
 position:absolute;
 top:5px;
    right:5px;
    cursor:pointer
}
.inner{
    position:relative;
        padding-top:50px;
}

http://jsfiddle.net/9BrUN/1/ http://jsfiddle.net/9BrUN/1/

in your case Echo 在你的情况下回声

echo'
<script type="text/javascript">
$(document).ready(function(){modal()}});
<script>';

You cannot modify the alert box. 您无法修改警告框。 Instead of alert, use something like: 而不是警报,使用如下:

jQuery: jQuery的:

  $('body').append('<div class="error"><span class="error_close">×</span>Greška!<br>Molimo Vas ispravno popunite obrazac.</div>');
$('.error_close').click(function(){$(this).parent().hide();});

CSS: CSS:

.error { position: fixed; z-index: 10000; top: 0; left: 0; right: 0; bottom: 0; margin: auto; width: 400px; height: 100px; } 
.error_close { position: absolute; top: 5px; right: 5px; } 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM