2011-08-02 149 views
0
<!DOCTYPE html> 
<html> 
<head> 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script> 
<style type="text/css"> 
#myDialog{ 
    width:19%; 
    height:170px; 
    -moz-border-radius: 10px; 
    -webkit-border-radius: 10px; 
    border-radius: 10px; 

} 
#hqalert{ 
    width:100%; 
    height:30px; 
    background: -moz-linear-gradient(top, rgba(99,182,219,1) 29%, rgba(48,157,207,1) 52%); 
    -moz-border-radius: 10px; 
    -webkit-border-radius: 10px; 
    border-radius: 10px; 
} 
</style> 
<script type='text/javascript'> 
function myinf(that) 
{ 
if(that.value>15){ 
document.getElementById("myDialog").style.borderColor="#6EB6D5"; 
document.getElementById("myDialog").style.borderWidth="0.1px"; 
document.getElementById("myDialog").style.borderStyle="solid"; 
document.getElementById("myDialog").style.display='block'; 
} 
} 
</script> 
</head> 
<body> 

     <input type="text" onblur="myinf(this)" value="12" id="smps"/> 
     <input type="button" id="one"/> 
     <div id="myDialog" style="display:none;" ><p id="hqalert">General Alert:</p></div> 
    </body> 
</html> 

运行上述html时,会显示警报。如果我们在文本框中输入一个大于15的值,它可以正常工作,但警报在顶部有空白。我怎样才能删除它?顶部的空白区域

回答

3

margin-top:0px;添加到#hqalert样式中。