【问题标题】:Hide elements in Sencha Touch but preserve CSS spacing在 Sencha Touch 中隐藏元素但保留 CSS 间距
【发布时间】:2013-05-06 08:31:26
【问题描述】:

我在 Sencha Touch 中有一个视图,其中包含许多不同的标签和按钮。我已在我的 custom.css 文件中将它们设置为我希望它们的外观。我想隐藏除一个按钮之外的所有内容,以便在单击按钮时出现元素。我在这些元素中添加了“隐藏:真实”。然而,CSS 被忽略并且样式很糟糕。有什么办法可以保存 CSS 吗?我看到我可以使用“hiddenCls”,但我不知道如何使用它。有什么想法吗?谢谢!

以下是我目前的代码:

Ext.define('myApp.view.StartScreen', {
extend: 'Ext.Container',
xtype: 'startscreen',

config: {
    layout: {
        type: 'vbox',
        align: 'middle'
    },

    items: [{
        xtype: 'toolbar',
        docked: 'top',
        title: 'My App',
        items: [{
            xtype: 'button',
            iconMask: true,
            iconCls: 'refresh',
            width: 42
        }, { xtype: 'spacer' }, {
            xtype: 'button',
            iconMask: true,
            iconCls: 'user'
        }]
    }, {
        xtype: 'label',
        html: 'Discussions',
        cls: 'item-title-label',
        name: 'itemTitleLabel',
        hidden: true,
        hiddenCls: 'x-item-title-label-hidden'
    }, {
        xtype: 'label',
        html: 'Hi',
        cls: 'case-number-label',
        name: 'caseNumberLabel',
        hidden: true,
        hiddenCls: 'x-case-number-label-hidden'
    }, {
        xtype: 'label',
        html: '0:00',
        cls: 'duration-label',
        name: 'durationLabel',
        hidden: true,
        hiddenCls: 'x-duration-label-hidden'
    }, {
        xtype: 'label',
        html: 'Started at 13:42',
        cls: 'time-started-label',
        name: 'timeStartedLabel',
        hidden: true,
        hiddenCls: 'x-time-started-label-hidden'
    }, {
        xtype: 'button',
        text: 'Start',
        ui: 'confirm',
        cls: 'big-start-button',
        name: 'bigStartButton'
    }, {
        xtype: 'button',
        text: 'Off',
        ui: 'decline',
        cls: 'big-off-button',
        name: 'bigOffButton',
        hidden: true,
        hiddenCls: 'x-off-button-hidden'
    }]
}

});

【问题讨论】:

    标签: css sencha-touch sencha-touch-2 visibility hidden


    【解决方案1】:

    尝试在要隐藏的元素上使用 css 属性 visiibility,如 visibility:hidden

    【讨论】:

    • 谢谢,这行得通。但是如何使用 JavaScript 中的 Sencha Touch 代码将可见性设置为 true?
    • @bnrq 我不知道,但您可以使用一个类(例如 .hidden{visibility :hidden})并将该类添加到您要隐藏的组件中。
    • 我真的想通了!我可以只使用 getElementById 然后将可见性设置为“可见”(例如:itemTitle.style.visibility = 'visible')。感谢您的帮助!
    猜你喜欢
    • 2021-08-25
    • 2023-03-16
    • 1970-01-01
    • 2013-08-29
    • 2012-07-13
    • 2015-11-24
    • 2011-09-17
    • 2013-05-16
    • 1970-01-01
    相关资源
    最近更新 更多