Kpt.Khaos
Kpt.Khaos

Reputation: 693

HTML table Width = "100%" still didn't fit to window size in ASP.Net

I have a html table for displaying data. I have the typical width="100%"; but it did not work. Here is what my page looks like and my CSS/HTML styling. How can I fix it to auto fit the screen?

Code:

<table style="border: medium solid #FFFFFF; background-color: #000000; position: fixed;"
             border="3" width="100%";>

Upvotes: 3

Views: 46461

Answers (4)

DreamTeK
DreamTeK

Reputation: 34177

You have 100% width plus a border. This is greater than 100%.

HTML

<table class="tbl" cellspacing="0" cellpadding="0">

CSS

.tbl{
    position:fixed;
    width:100%;
    border:3px solid #fff;
    background:#000;
    box-sizing:border-box; /* causes item size to include border and padding */
    -moz-box-sizing:border-box; /*for browser compatibility*/
}

Upvotes: 0

user2088260
user2088260

Reputation:

add these lines in your style

*{margin:0; padding:0;} 

Upvotes: 0

frogatto
frogatto

Reputation: 29285

Add this CSS:

body {
    margin: 0
}

Because the default margin for body element in not 0

Upvotes: 1

SW4
SW4

Reputation: 71150

Make sure your body element has padding and margin set to 0

Without setting this vs when this is set

html, body{
    height:100%;
    width:100%;
    padding:0;
    margin:0;
}

Upvotes: 8

Related Questions