Skip to content Skip to sidebar Skip to footer

Resize Issue With Table Centered Horizontally And Vertically

Simple code
my content
and style .box { wid

Solution 1:

Give a minimum height to your document:

html{
  position:relative;
  height: 100%;
  min-height: 300px;
}

That way the height of the window will never be smaller than the box.

(height:100% is needed so your box gets centered)


...even with scroll-bar shown,

you see the scrollbars because there's content that overflows, but the height of the html does not include that extra space (when the negative margin is applied, it does not take into consideration that extra height)

Solution 2:

.box {
    width:50%;
    height:50%;
    background-color:#d9d9d9;
    position:absolute;
    top:25%;
    left:25%;
}

Solution 3:

.box {
    width:50%;
    height:50%;
    background-color:#d9d9d9;
    position:absolute;
    margin-left:-150px;
    /* half of width */
    margin-top:-150px;
    /* half of height */top:50%;
    left:50%;
}

.top {

    margin-left:2cm;
    margin-right:2cm;
    vertical-align:text-top;
}


html

<table class="box" border="1px">
  <tr><tdclass="top">my content</td></tr>

Post a Comment for "Resize Issue With Table Centered Horizontally And Vertically"