js
<script src="/${res}/agency/js/jquery.min.js"></script>
<script type="text/javascript">
msgAlert();
function closeMsg(){
$('#msg-alert').hide();
}
function msgAlert(){
$('#msg-alert').show();
window.setTimeout(closeMsg,1500);
}
</script>
css
<style type="text/css">
#msg-alert {
z-index: 9999;
position: fixed;
top: 50%;
left: 50%;
width: 182px;
height: 82px;
margin-left: -91px;
margin-top: -41px;
border-radius: 2px;
background-color: #2a2a2a;
display: none;
box-shadow: 0 0 1px #666;
opacity: 0.9;
text-align: center;
line-height: 82px;
color: #fff;
font-size: 18px;
font-family: "微軟雅黑"
}
</style>
html
<span id="msg-alert">
<span class="glyphicon glyphicon-info-sign" style="font-weight:100;"></span> 手機號不能爲空
</span>
效果圖