How to position controls on web page

J

Jeff Cooper

Hey folks,

Silly question from someone just starting out on this...

I've tried both the old <center></center> tags and <div align=center></div>
and they seem to be ignored when I view the page in a browser. I used the
designer to add an image control to the page. I'd like that image to be
centered. The code that it added is:

<asp:Image id="Image1" style="Z-INDEX: 101; LEFT: 60px; POSITION: absolute;
TOP: 44px" runat="server"
Width="800px" Height="600px"></asp:Image>

Now, what do I do -- specifically please -- to that code, or around it, to
make it center in the browser window (and remain centered as the browser is
resized. Just like it would if I typed <center><img ..></center> in the
nodepad.

Also, I really don't care at this point if I'm using an image control or an
img html tag -- whatever works.

Thanks,

Jeff
 
K

Ken Cox [Microsoft MVP]

Hi Jeff,

When you (or the visual designer) set the image style for POSITION: absolute,
the browser won't reposition it in the centre. It becomes relative to the
top-left of something.

You could put it inside a one-row table and centre it:

<table id="Table1" cellspacing="0" cellpadding="0" width="100%"
border="0">
<tr>
<td align="center">
<asp:image id="Image1" runat="server" width="800px" height="600px"
imageurl="http://www.gc.ca/images/rollingflag.jpg"></asp:image>
</td>
</tr>
</table>

or even inside a paragraph that is centred:

<p align="center">
<asp:image id="Image1" runat="server" width="800px" height="600px"
imageurl="http://www.gc.ca/images/rollingflag.jpg" />
</p>

Ken

--

Important: Patch Windows *beyond* Blaster.
http://www.microsoft.com/technet/security/bulletin/MS03-039.asp


Hey folks,

Silly question from someone just starting out on this...

I've tried both the old <center></center> tags and <div align=center></div>
and they seem to be ignored when I view the page in a browser. I used the
designer to add an image control to the page. I'd like that image to be
centered. The code that it added is:

<asp:Image id="Image1" style="Z-INDEX: 101; LEFT: 60px; POSITION: absolute;
TOP: 44px" runat="server"
Width="800px" Height="600px"></asp:Image>

Now, what do I do -- specifically please -- to that code, or around it, to
make it center in the browser window (and remain centered as the browser is
resized. Just like it would if I typed <center><img ..></center> in the
nodepad.

Also, I really don't care at this point if I'm using an image control or an
img html tag -- whatever works.

Thanks,

Jeff
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top