html5 - Centering div in a document -


i know question has been asked many times before, none of answers have worked me. coding in html5 , css 3.0. trying center div tag in page, contains 3 thumbnails link other pictures. want pictures sit next each other, margin of 0 (so they'll touch each other). here html code have:

<div id="main">     <h1>hello</h1>     <div id="gallery">         <a class="trigger" href="images/fulls/01.jpg">             <img class="thumb" src="images/thumbs/01.jpg">         </a>         <a class="trigger" href="images/fulls/02.jpg">             <img class="thumb" src="images/thumbs/02.jpg">         </a>         <a class="trigger" href="images/fulls/03.jpg">             <img class="thumb" src="images/thumbs/03.jpg">         </a>     </div> </div> 

the css:

body {     font-family: arial;     background: darkgray;     color:white;     text-shadow:1px 1px 3px black;     text-align: center; } #gallery {     text-align: center;     width: 462px; } .trigger {     position: relative;     display: block;     float: left; } 

this results in title "hello" being centered, , 3 thumbnails stuck left. have no distance between them, , aligned in row expected, cannot them center.

you need remove float:left images , use display: inline-block; add margin: 0 auto; #gallery

demo: http://jsfiddle.net/dc5af/


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 -