I have a very simple problem, but I can't seem to solve it. I have a table inside a div, which is the main element. Now I have a td tag inside the table with a width and hight set to that of an iphone screen size. Now I basically want to center that table with its td cell within the div tag, so that the 'screen' will be centered in any browser window. How do I do that?
Replacing that div with a table solved my problem, but I would like to use a div instead.
Thank You
Try this one , I do this code - Demo here, Very easy and simple code ( I have used a hack code and extra span tag for only IE old version) http://jsfiddle.net/ERuX4/1/
<div class="demo wraptocenter">
<span></span>
<img src="http://www.spitzer.caltech.edu/images/twitter.png?1295473781" alt="" />
</div>
css
.wraptocenter * {
vertical-align: middle;
}
.wraptocenter span {
display: inline-block;
height: 100%;
width: 1px;
}
.wraptocenter {
display: table-cell;
text-align: center;
vertical-align: middle;
}
/*End wraptocenter - image Vcenter patch styles*/
.demo {
width:100px;
height:100px;
border:1px solid red;
position:absolute;
top:50%;
left:50%;
margin-top:-100px;
margin-left:-100px;}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With