473,287 Members | 1,709 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,287 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 2613
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: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

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.