css - How to center a div tag in a html page without being affected by zooming -


i've html page div tags in it, want put container div in center of computer screen whether zoom-in or zoom-out.

i want modify html page in such manner www.bing.com. homepage centers on screen when zoom-out, whereas, web page continuously expands while zooming.

my html pagecode:

 <html>       <head>         <title>           html test page         </title>         <style>           .horizontal{         width:100%;         height:100px;         background-color: #bbb;           }           .vertical{         width:100px;         height:70%;         background-color: #bbb;           }           #container{         margin:auto;         width:100%;         height:100%;           }         </style>       </head>       <body>         <div id="container">         <div class="horizontal">         </div>         <div class="vertical" style="float:left;">         </div>         <div class="vertical" style="float:right;">         </div>         <div class="horizontal" style="float:left;" >              </div>         <h1 style="font-size:3em; color:green; text-align:center;">              html test page         </h1>         </div>       </body>     </html> 

how adjust css code can implement centralized page style same of (www.bing.com)? want centralize container div on pressing ctrl+-

after looking bing page referred us, believe want this

    <html>       <head>         <title>             html test page         </title>         <style> body {     width: 100%;     height: 100%;     margin:auto; } #container {     vertical-align: middle;     margin:auto;     height:100%;     width:100%;     display: table; } span {     display: table-cell;     vertical-align: middle;     text-align:center;     font-size:5em;     color:#fff; } #inner {     margin:auto;     width:50%;     height:auto;     border:100px solid #bbb;     color:green;}         </style>       </head>       <body>     <body>         <div id="container">         <div class="horizontal">             </div>             <div class="vertical" style="float:left;">             </div>             <div class="vertical" style="float:right;">             </div>             <div class="horizontal" style="float:left;" >                  </div>             <span><div id="inner">html test page</div>             </span>         </div>     </body>       </body>     </html> 

this creates 100px sized border div, aligned in center want


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -