How to center the page in browser?

C

charlies224

Hi,

I have been searching for a way to display my whole web page at the
center of the browser.

Basically, I created a web application and created a web form with a
table in it.

I tried the following:

1) put the align=center inside my <table> tag

2) wrap my table in <center></center> tags

3) put
<style>
myTable
{
margin-left: auto;
margin-right:auto;
}
</style>

then set <table style=myTable>

none of the above works for me, the whole table still show up at the
left top corner of the web page.


Could someone please give me an hand on this?

Thank you,

Charlie Chang
<[email protected]>
 
U

Umut Tezduyar

Try this:

<table width="100%" height="100%">
<tr>
<td align=center valign=middle>
<!--Your web page will be located here -->
</td>
</tr>
</table>
 
C

charlies224

Thanks for the reply, but sadly, It does not work either...
I post the whole codes here, maybe it's something else that went wrong.

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="myTest.aspx.vb" Inherits="WebApplication1.myTest"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>myTest</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<table width="100%" height="100%">
<tr>
<td align=center valign=middle>
<TABLE id="Table1" style="Z-INDEX: 101; LEFT: 8px; POSITION:
absolute; TOP: 8px" borderColor="#cc9900"
cellSpacing="1" cellPadding="1" width="300" border="1">
<TR>
<TD>a</TD>
<TD>b</TD>
<TD>c</TD>
</TR>
<TR>
<TD>e</TD>
<TD>f</TD>
<TD>g</TD>
</TR>
<TR>
<TD>h</TD>
<TD>i</TD>
<TD>j</TD>
</TR>
</TABLE>
</td>
</tr>
</table>
</form>
</body>
</HTML>

Charlie
 
C

charlies224

Honestly,

I am a programmer and I don't like web projects - these projects are
more suited for designers -, I do know the OO concept (managed,
reusable... blah blah blah) with the CSS...
but what I am trying to do here is something that's quick and dirty
especially that I don't have a picky web site admin on my back and the
site is small anyway.

asp .net + some cheap yet nice-looking flash movies / photos with
effect = a decent website done in less than 5 days. ^_^


Horrible the markup may look, but work it will.

Thx for the link :)

Charlie
 
N

neilphan

Hi...

The problem is not with your TABLE...its with your ENTIRE PAGE...Your
PAGE BODY is currenlty set to "GRID LAYOUT" which means that every
object you place on your page will have STATIC POSITION based on where
you PLACE these objects on your form while using the Visual Studio Form
Designer.

To correct this, change the PAGE LAYOUT to "FLOW LAYOUT" and you should
be fine. Make sure that all of your Web Control Ojects remove all tag
attributes that has STATIC POSITION.

I personally ONLY use FLOW LAYOUT.

Have Fun,
Neil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top