473,466 Members | 1,313 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to center the page in browser?

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
<!-************@hotmail.com-->

Nov 23 '05 #1
7 1972
Try this:

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

<ch*********@hotmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
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
<!--ch*********@hotmail.com-->

Nov 23 '05 #2
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

Nov 23 '05 #3
Remove the style > z-index part in your inner table. Z-Index style says
that, the page will be located in a static part in the browser.

Check this out:
http://msdn.microsoft.com/library/de...ies/zindex.asp

<ch*********@hotmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
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

Nov 23 '05 #4
Yuk!! That markup looks horrible! What ever happen to CSS.
http://builder.com.com/5100-6371_14-5296198.html

Nov 23 '05 #5
That solves the problem...

Thank you for your help :)

Charlie

Nov 23 '05 #6
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

Nov 23 '05 #7
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

Nov 23 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Tony Vasquez | last post by:
Can somoene give me an example of how to center a div, according to it's image size... I am using different images, and so I have to resize it in a functino according to the image's size. So I use...
27
by: FL | last post by:
Hi Everyone, I know howto center a block using margin-left: auto ; margin-right: auto ; but I'm trying to center vertically a box, any idea to solve this?
10
by: john T | last post by:
Is there anyway to vertically center a html table using css in such a way it does not alter the html table. When I tryied it just screws up.
11
by: Mark Schneider | last post by:
I'm trying to avoid using <table> for formatting purposes where other, reasonable means exist. I'm stuck trying to find a way to find an equivalent for the code below. <table align="center">...
4
by: cmo | last post by:
What I'm trying to do is to display a loading screen while an ajax request executes. I have a page that is fairly long with several tables worth of data and the sorting/pagination of each table is...
1
by: judacris | last post by:
I've seen the threads here about molding 2 divs in a centered fashion. but I can't seem to solve this thing. my blogger blog is functioning well on my site for now, but the blog feed (left) and...
2
by: rowe_newsgroups | last post by:
Hello all, I have something I believe is something simple, but I can't seem to figure out what to do. I did some searching, but I either can't get my search right. Anyways, on a new webpage I'm...
3
by: Max2006 | last post by:
Hi, I have the following code to show the UpdateProgress contents at the center of page: <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1"...
4
by: trint | last post by:
I have SetFocus(GridView1) set to the gridview. However, it just goes to the left edge of the control instead of making it visible in the center of the aspx page. Any help is appreciated....
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.