html - Centering an article tag -


i trying center content of html article element. content aligns left margin of page. here html using:

<article>      <h1>sign in</h1>     <div class="display-new">         <form action="" method="post">             <div class="label-field">                 <label for="email">email: </label>                 <input type="text" name="email" />             </div>             <div class="label-field">                 <label for="password">password: </label>                 <input type="password" name="password" />             </div>             <input type="submit" value="sign in" class="submit-button"/>         </form>     </div>     <div class="forgotten-password">          <a href="../index.php?action=resetpassword">forgotten password?</a>     </div> <!-- end forgotten-password --> </article> 

here css:

html {     position: relative;     min-height: 100%; }  body {     font-family: sans-serif;     color: #3e3e3e;     margin: 0 0 3rem; /* bottom = footer height */ }  footer {     position: absolute;     height: 3rem;     min-width: 100%;     bottom: 0;     padding: 0;     font-size: small;     background-color: #fff;     text-align: center;     /*border: 1px solid red;*/     margin: 0 auto; }  p, ul {     margin: 0 0 1.5em;     color: #838383; }  ul {     list-style: disc;     padding: 0 0 0 10px;     top: 0; }  h1, h2 {     margin: 0 0 10px;     font-size: 1.3em;     font-weight: bold;      text-align: center; }  article {     max-width: 768px;     margin-left: auto;     margin-right: auto;     text-align: center;     font-size: medium; }  .wrapper {     margin-left: auto;     margin-right: auto;     margin-bottom: 50px;     /*margin-bottom: 50px;*/     min-height:100%; }  .content {     max-width: 60%;     margin: 0 auto;     /*padding-bottom: 5em;*/     min-height: 100%;     font-size: 1.4rem;     font-size: 14px; }   /* ==== form classes ==== */ form {     width: auto; }  div.display-new {     margin: 0 auto;  }  form div.label-field {     position: relative;     margin: 0 auto;     padding: 5px 0;     text-align: left; }  form div.label-field label, form div.label-field input {     display: block; }  div.forgotten-password {     margin: 10px auto;     font-size: smaller; }  div.forgotten-password {     text-decoration: none; } 

and here fiddle showing issue. unsure happening here. there lot of questions on stackoverflow related centering, , google search identifies quite few articles on subject. have trawled through lot of these , tried various answers. however, this answer gives general clue issue. trouble don't understand answer saying. please explain understanding amiss please? , maybe use issue illustration?

okay! happening here is:

  1. your article tag centered, can see changing background colour of tag (i changed red):

article

  1. your "display-new" div 1 causing form align left. (again changed background colour can see):

display-new

  1. one option give display-new set width, contains form. using margin: 0 auto, centre:

http://jsfiddle.net/hhvbts7l/8/

.display-new {     width: 150px;     margin: 0 auto;     background: blue;     text-align: left !important; } 

but knowing can figure out own way!


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -