How to center a label?

  1. #1

    How to center a label?

    No matter what a try I cannot seem to center the contents of a label? Setting a text-align:center in css doesn't seem to work. How is the ext:CenterLayout used? The CenterLayout example doesn't even use a ext:CenterLayout tag.

    The idea would be a status message on a form, but I want it centered. Labels default to left align and I can't seem to override that.

    For example, i want the label only on this sample form below to center it's contents. Why is there no Align (contents) options for tags? Wrapping it with a ext:CenterLayout doesn't work.

    <ext:Panel>
    <Items>
       <ext:TextField/>
       <ext:TextField/>
       <ext:TextField/>
       <ext:Label ID="errorMessage" Align="center" Cls="red" />
    </Items>
    </ext:Panel>
    Last edited by geoffrey.mcgill; Dec 15, 2011 at 7:27 PM. Reason: please use [CODE] tags
  2. #2
    I'm working on a sample for you, although as a quick note and friendly reminder, please ensure you wrap your code samples in [CODE] tags.

    This will help with auto formatting and readability.
    Geoffrey McGill
    Founder
  3. #3
    Quote Originally Posted by geoffrey.mcgill View Post
    I'm working on a sample for you, although as a quick note and friendly reminder, please ensure you wrap your code samples in [CODE] tags.

    This will help with auto formatting and readability.
    Thank you! Were you able to work up a sample on how to center things...buttons or components, etc. in a panel?
  4. #4
    Hi,

    It's not always possible to centralize a thing using CSS only. In such cases you should set up a respective layout.

    Please provide a mockup how the things should look, then we will suggest a layout.
  5. #5
    Quote Originally Posted by Daniil View Post
    Hi,

    It's not always possible to centralize a thing using CSS only. In such cases you should set up a respective layout.

    Please provide a mockup how the things should look, then we will suggest a layout.
    I simply want to center something like the label in the panel below. It's unclear how I can center 'anything' in a panel. I was hoping there would be a 'align' attribute or something to make it easy but it seems very convoluted to center anything, having to resort to tricks. You can center buttons on a panel using the ButtonAlign="Center" but it only applies to buttons obviously.

    <ext:Panel>
    <Items>
       <ext:TextField/>
       <ext:TextField/>
       <ext:TextField/>
       <ext:Label ID="errorMessage" Align="center" Cls="red" />
    </Items>
    </ext:Panel>
  6. #6
  7. #7
    As well you can look at this example:
    http://forums.ext.net/showthread.php...ll=1#post53771

Similar Threads

  1. Replies: 2
    Last Post: Jun 23, 2012, 2:17 PM
  2. [CLOSED] Label Style / Obtain label color based on theme
    By rthiney in forum 1.x Legacy Premium Help
    Replies: 11
    Last Post: Apr 15, 2010, 10:35 AM
  3. to Add a tab in center is not working
    By Sameera in forum 1.x Help
    Replies: 0
    Last Post: Jan 26, 2010, 5:58 PM
  4. [CLOSED] Hi how to align the label text to center?
    By Etisbew in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 13, 2009, 11:03 AM
  5. Center label in statusbar?
    By dbassett74 in forum 1.x Help
    Replies: 0
    Last Post: May 07, 2009, 12:10 PM

Tags for this Thread

Posting Permissions