是否可以在nativescript中更改类标签的CSS属性

时间:2019-01-26 09:34:43

标签: css nativescript

我为项目中的每个标签都使用了标签类。如果还有其他字体颜色,例如

  

class =“ label font-clr-green”

应用

则它不呈绿色。因此,我决定覆盖app.css中的label类,但这也是失败的。我需要知道标签类是否可以被覆盖。

1 个答案:

答案 0 :(得分:0)

我检查了您的Playground示例,并从中得出的结论是,问题部分使用的<Label>没有采用应有的绿色。嗯,那是因为您正在<Label><StackLayout>中使用这个input-field元素。看来.input-field Label的CSS是预先定义的。

解决您的问题的方法是将此类input-field重命名为其他名称。仅此而已。以下是更新的XML部分。您还可以通过修复程序检查我随附的Playground演示。

<Page loaded="pageLoaded" class="page" xmlns="http://www.nativescript.org/tns.xsd">

<ActionBar title="Home" class="action-bar">
</ActionBar>
<ScrollView>
    <StackLayout class="form">
        <!--this was working fine -->
        <Label textWrap="true" text="Play with NativeScript!" class="label font-weight-bold m-b-5 fcg" /> 
        <Label textWrap="true" text="Play with NativeScript!" class="label font-weight-bold m-b-5"
            color="green" />


        <!-- the problem was here, solution was to rename input-field to input-field-1  -->
        <StackLayout class="input-field-1">
            <StackLayout class="okay">
            <Label text="Active Flag" class="label font-weight-bold m-b-5 fcg" />
            </StackLayout>
            <Switch checked="true" class="switch fcg"
                horizontalAlignment='left' margin="0" />
            <StackLayout class="hr-light"></StackLayout>
        </StackLayout>

    </StackLayout>
</ScrollView>

工作Playground Demo