div顶部的空白区域

时间:2011-08-02 06:35:56

标签: javascript css

<!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的值,则它可以正常工作,但警报顶部有空白区域。我该如何删除它?

1 个答案:

答案 0 :(得分:3)

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

相关问题