html - Why does my border go over my form? -
when make browser window smaller border not stay around form, instead overlap? sentence. how make border stay around the form , have border height adjust length of form padding?
#form_border{      margin: auto;      width: 400px;             border-style: solid;      border-color: black;      border-width: 1px;                  }  #form {              width: 50%;      height: 50%;      margin: auto;      padding-top: 2em;      text-align: center;                        }  #form form{display: block;}  #existing_account{ text-align: center;                     text-decoration: none;                     color: black;  }            input[type=submit] {                      background:white;                      border:1px solid;                      border-color: #292929;                      cursor:pointer;                      border-radius: 5px; }         input[type=submit] {                      background:white;                      border:1px solid;                      border-color: #292929;                      cursor:pointer;                      border-radius: 5px; }<div id="form_border">      <form id="form" method="post" action="">          <p>username:<br> <input type="text" name="user_name" /> <br></p>          <p>password:<br> <input type="password" name="user_pass"><br></p>          <p>password again:<br> <input type="password" name="user_pass_check"><br></p>          <p>e-mail:<br> <input type="email" name="user_email"><br></p>          <input type="submit" value="sign up" />       </form>          <a id="existing_account" href="sign_in.php">already have account?</a>      </div>
try using code:
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta content="text/html; charset=utf-8" http-equiv="content-type"> <style> #form_border{     margin: auto;     width: 400px;      border-style: solid;     border-color: black;     border-width: 1px; } #form {     width: 50%;     height: 50%;     margin: auto;     padding-top: 2em;     text-align: center; } #form form{     display: block; } #existing_account{      text-align: center;     text-decoration: none;     color: black; } input[type=submit] {     background:white;     border:1px solid;     border-color: #292929;     cursor:pointer;     border-radius: 5px;  }    @media screen , (max-width:399px){     input[type="text"],     input[type="password"],     input[type="email"]{         width:90%;     }     #form_border{         width:98%;     }     #form {         width: 50%;         height: 50%;     } } </style> </head> <body> <div id="form_border">     <form id="form" method="post" action="">         <p>username:<br> <input type="text" name="user_name" /> <br></p>         <p>password:<br> <input type="password" name="user_pass"><br></p>         <p>password again:<br> <input type="password" name="user_pass_check"><br></p>         <p>e-mail:<br> <input type="email" name="user_email"><br></p>         <input type="submit" value="sign up" />      </form>         <a id="existing_account" href="sign_in.php">already have account?</a>     </div> </body> </html> you observe:
- i have introduced media query manage form size screens less 400px in width.
- width of form , form-elements has been taken care of in media query.
scope improvements:
- restructure html becomes more manageable. 
- use media queries more efficiently. 
- use - widthvalues more efficiently.
you use jsfiddle.net demo link.
here few more commonly used media query break points may consider including in css
/* smartphones (portrait , landscape) ----------- */ @media screen , (min-device-width : 320px) , (max-device-width : 480px) { /* styles */ }  /* smartphones (landscape) ----------- */ @media screen , (min-width : 321px) { /* styles */ }  /* smartphones (portrait) ----------- */ @media screen , (max-width : 320px) { /* styles */ }  /* ipads (portrait , landscape) ----------- */ @media screen , (min-device-width : 768px) , (max-device-width : 1024px) { /* styles */ }  /* ipads (landscape) ----------- */ @media screen , (min-device-width : 768px) , (max-device-width : 1024px) , (orientation : landscape) { /* styles */ }  /* ipads (portrait) ----------- */ @media screen , (min-device-width : 768px) , (max-device-width : 1024px) , (orientation : portrait) { /* styles */ } /********** ipad 3 **********/ @media screen , (min-device-width : 768px) , (max-device-width : 1024px) , (orientation : landscape) , (-webkit-min-device-pixel-ratio : 2) { /* styles */ }  @media screen , (min-device-width : 768px) , (max-device-width : 1024px) , (orientation : portrait) , (-webkit-min-device-pixel-ratio : 2) { /* styles */ } /* desktops , laptops ----------- */ @media screen  , (min-width : 1224px) { /* styles */ }  /* large screens ----------- */ @media screen  , (min-width : 1824px) { /* styles */ }  /* iphone 4 ----------- */ @media screen , (min-device-width : 320px) , (max-device-width : 480px) , (orientation : landscape) , (-webkit-min-device-pixel-ratio : 2) { /* styles */ }  @media screen , (min-device-width : 320px) , (max-device-width : 480px) , (orientation : portrait) , (-webkit-min-device-pixel-ratio : 2) { /* styles */ }  /* iphone 5 ----------- */ @media screen , (min-device-width: 320px) , (max-device-height: 568px) , (orientation : landscape) , (-webkit-device-pixel-ratio: 2){ /* styles */ }  @media screen , (min-device-width: 320px) , (max-device-height: 568px) , (orientation : portrait) , (-webkit-device-pixel-ratio: 2){ /* styles */ }  /* iphone 6 ----------- */ @media screen , (min-device-width: 375px) , (max-device-height: 667px) , (orientation : landscape) , (-webkit-device-pixel-ratio: 2){ /* styles */ }  @media screen , (min-device-width: 375px) , (max-device-height: 667px) , (orientation : portrait) , (-webkit-device-pixel-ratio: 2){ /* styles */ }  /* iphone 6+ ----------- */ @media screen , (min-device-width: 414px) , (max-device-height: 736px) , (orientation : landscape) , (-webkit-device-pixel-ratio: 2){ /* styles */ }  @media screen , (min-device-width: 414px) , (max-device-height: 736px) , (orientation : portrait) , (-webkit-device-pixel-ratio: 2){ /* styles */ }  /* samsung galaxy s3 ----------- */ @media screen , (min-device-width: 320px) , (max-device-height: 640px) , (orientation : landscape) , (-webkit-device-pixel-ratio: 2){ /* styles */ }  @media screen , (min-device-width: 320px) , (max-device-height: 640px) , (orientation : portrait) , (-webkit-device-pixel-ratio: 2){ /* styles */ }  /* samsung galaxy s4 ----------- */ @media screen , (min-device-width: 320px) , (max-device-height: 640px) , (orientation : landscape) , (-webkit-device-pixel-ratio: 3){ /* styles */ }  @media screen , (min-device-width: 320px) , (max-device-height: 640px) , (orientation : portrait) , (-webkit-device-pixel-ratio: 3){ /* styles */ }  /* samsung galaxy s5 ----------- */ @media screen , (min-device-width: 360px) , (max-device-height: 640px) , (orientation : landscape) , (-webkit-device-pixel-ratio: 3){ /* styles */ }  @media screen , (min-device-width: 360px) , (max-device-height: 640px) , (orientation : portrait) , (-webkit-device-pixel-ratio: 3){ /* styles */ } 
Comments
Post a Comment