Centering Label Text

J

Joe Delphi

Hi,

I want to position label text so that it always appears centered when
the user re-sizes the browser window.

I tried adding the HTML property text-align="CENTER" to the code,
but ASP.NET doesn't seem to recognize this HTML attribute.

Can someone tell me how to do this?


JD
 
P

PeterKellner

Hi,

I want to position label text so that it always appears centered when
the user re-sizes the browser window.

I tried adding the HTML property text-align="CENTER" to the code,
but ASP.NET doesn't seem to recognize this HTML attribute.

Can someone tell me how to do this?


JD

My strategy is to always wrap the label in a table with center set
like the following:

<table>
<tr>
<td style="text-align: center;width: 500px;">
<asp:Label ID="Label1" runat="server"
Text="Label"></asp:Label></td>
</tr>
</table>
Peter Kellner
http://peterkellner.net
 
J

John Timney \( MVP \)

try the code below

--
Regards

John Timney
Microsoft MVP





<%@ Page Language="C#" Debug="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>
<meta http-equiv="content-type" content="text/html;charset=ISO-8859-1">
<title>Dead Centre Controls Example</title>
<style type="text/css" media="screen"><!--
body
{
color: white;
background-color: white;
margin: 0px
}

#horizon
{
color: white;
background-color: transparent;
text-align: center;
position: absolute;
top: 50%;
left: 0px;
width: 100%;
height: 1px;
overflow: visible;
visibility: visible;
display: block
}

#content
{
font-family: Verdana, Geneva, Arial, sans-serif;
background-color: transparent;
margin-left: -125px;
position: absolute;
top: -35px;
left: 50%;
width: 250px;
height: 70px;
visibility: visible
}

...bodytext
{
font-size: 14px
}

...headline
{
font-weight: bold;
font-size: 24px
}

#footer
{
font-size: 11px;
font-family: Verdana, Geneva, Arial, sans-serif;
text-align: center;
position: absolute;
bottom: 0px;
left: 0px;
width: 100%;
height: 20px;
visibility: visible;
display: block
}

a:link, a:visited
{
color: #06f;
text-decoration: none
}

a:hover
{
color: red;
text-decoration: none
}

--></style>
</head>

<body>
<div id="horizon">
<div id="content">
<div class="bodytext">

<body>

<form runat="server">


<aspPanel id="Panel1" runat="server"
style="padding:15,15,15,15;
background-color:red;
border-color:black;border-width:1;
border-style:solid">

<asp:Label id="Label1"
Text="Some Centered Controls"
Font-Name="verdana"
Font-Size="12"
runat="server"/>

</aspPanel>
</form>


</div>
</div>
</div>

</body>

</html>
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top