473,404 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Centering Label Text

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
May 16 '06 #1
2 2618
On Tue, 16 May 2006 09:13:57 -0700, "Joe Delphi"
<de*******@nospam.cox.net> wrote:
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
May 16 '06 #2
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>

"Joe Delphi" <de*******@nospam.cox.net> wrote in message
news:aTmag.690$rS6.601@fed1read11...
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

May 16 '06 #3

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

Similar topics

15
by: red | last post by:
How do I center two side by side divs ? I've been writing css pages for a while but there's one thing tha still eludes me. I can center a div with margin auto. I can place two divs side by side...
4
by: Todd | last post by:
I am adding a Label control to a page that I am going to be dynamically setting the text during runtime and I want to center the control. I can't figure out how to center it. Does anyone know? ...
2
by: Todd | last post by:
I am adding a Label server control to an ASPX page using the .NET IDE. I can't figure out how to center it automatically. I know you can do it by editing the html and making it: <asp:Label...
1
by: Brian Conway | last post by:
Is there a way to center text inside a label in a webform?
16
by: tshad | last post by:
I am trying to center a button in a datagrid column in asp.net and it doesn't seem to work. I have the following: <asp:TemplateColumn ItemStyle-Width="10%" ItemStyle-HorizontalAlign="Center">...
3
by: John Pote | last post by:
1. Horizontal centering a <divin browser window. The current trend seems to be to place page content in a fixed width area in the middle of the browser window. How is this achieved? If I use a...
5
by: Markus Ernst | last post by:
Hello This is a test example: http://www.markusernst.ch/anthracite/ http://www.markusernst.ch/anthracite/living_divani.html After googling and experimenting for several hours, I ended up...
1
by: Uriah Piddle | last post by:
Hi Gang, I have a horizontal asp menu in a div. I centered the menu by setting the text-align prop of the div to 'center' and that works in IE. But with the other browsers, the menu aligns left....
1
by: K Viltersten | last post by:
I'm playing around with the XAML-builder in VS2k8 and it seems that <Label Height="28" Margin="0,10,0,0" Name="label1" VerticalAlignment="Top" TextBlock.TextAlignment="Center"></Label> ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.