2 Replies Latest reply on Jul 10, 2007 12:57 PM by Newsgroup_User

    Using CSS Problem

    Level 7
      Why do I have to use class selector and not a type selector?

      <mx:Style>
      Label {
      fontSize: 16px;
      fontWeight: bold;
      }

      .test {
      fontSize: 16px;
      fontWeight: bold;
      }
      </mx:Style>
      ...
      <mx:Label text="Test" styleName="test"/>

      If I remove the styleName property telling the label to use the .test
      class, the label it NOT styled and I can not see why. I don't want to
      have to put classes on all my labels, I want them to be defined as a type.
        • 1. Re: Using CSS Problem
          Level 7
          Ok I finally noticed the debug information that I can not put type
          selectors in custom components. I don't see any discussion of this in
          the documentation I skimmed.

          Anyway I am having some funny behavior with my Label style deceleration
          that I moved to my base application file. It now does style my labels
          as desired, but it also styles nearly every other text in my application
          the same way. If I change the type to "Button" it works as expected,
          only styling my buttons. Is there some strange property of Label that I
          am not aware of at play here?

          <mx:Style>
          Label {
          font-size: 16px;
          font-weight: bold;
          }
          </mx:Style>



          • 2. Re: Using CSS Problem
            Level 7
            A simple test example showing what I am experiencing. Why should the
            text controls be inheriting the Label styling?

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="vertical">
            <mx:Style>
            Label {
            fontSize: 16px;
            fontWeight: bold;
            color: red;
            }

            .label {
            color: green;
            }
            </mx:Style>
            <mx:Label text="Type Selector"/>
            <mx:Text text="Just a text control"/>
            <mx:Label text="Class Selector" styleName="label"/>
            <mx:Text text="Another text control"/>
            </mx:Application>