简体   繁体   中英

White space in top of div

<!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>

When running the above html, it shows an alert. If we enter a value greater than 15 inside the text box it works fine, but the alert has white space at the top. How can I remove it?

Add margin-top:0px; to your #hqalert style.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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