如何在Sencha Touch 2中正确设置右边距?

时间:2011-10-20 18:44:13

标签: css sencha-touch margin sencha-touch-2

我正在研究这个应用程序,而且我似乎无法在屏幕右侧保持正确的边距。注意:顶部,底部和左侧工作正常。

Here's a screenshot
(出于某种原因,SO抱怨格式)

我有以下CSS样式

#rpc-view-home-indexview{
    margin: 5px;
}

这是我的JS View

Ext.define('rpc.view.home.indexView', {
    extend: 'Ext.Panel',
    id: 'rpc-view-home-indexview',  // This is where I'm setting the element for the margin
    alias: 'widget.home-indexView',
    config: {
       scroll: 'vertical',
       items: [{
           xtype: 'container',
           items: [{
               html: '<div class="rounded-div"><h1>RockPointe Church</h1><i>One church meeting in multiple locations.</i></div>'
           }]
       }, {
           // ...
       }]
    }
});

修改
如果有人关心,这里是相关的渲染html

<div class="x-body" id="ext-element-44">
    <div class="x-inner x-layout-card" id="ext-element-4">
        <div class="x-container x-panel x-layout-card-item" id="rpc-view-home-indexview" style="">
            <div class="x-body x-scroll-view" id="ext-element-24">
                <div class="x-scroll-bar-grid-wrapper" id="ext-element-23">
                    <div class="x-scroll-bar-grid">
                        <div>
                            <div></div>
                            <div>
                                <div class="x-scroll-bar x-scroll-bar-y" id="ext-element-22">
                                    <div class="x-scroll-indicator-csstransform x-scroll-indicator x-scroll-indicator-y"
                                         style="opacity: 0; -webkit-transform: translate3d(0px, 0px, 0px); "
                                         id="ext-component-2">
                                        <div id="ext-element-26"></div>
                                        <div id="ext-element-28"
                                             style="-webkit-transform: translate3d(0px, 0px, 0px) scaleY(570); top: 3px; "></div>
                                        <div id="ext-element-27"
                                             style="-webkit-transform: translate3d(0px, 573px, 0px); "></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div>
                            <div>
                                <div id="ext-element-18" class="x-scroll-bar x-scroll-bar-x">
                                    <div id="ext-component-1"
                                         class="x-scroll-indicator-csstransform x-scroll-indicator x-scroll-indicator-x"
                                         style="opacity: 0; -webkit-transform: translate3d(0px, 0px, 0px); ">
                                        <div id="ext-element-19"></div>
                                        <div id="ext-element-20"></div>
                                        <div id="ext-element-21"></div>
                                    </div>
                                </div>
                            </div>
                            <div></div>
                        </div>
                    </div>
                </div>
                <div id="ext-element-25" class="x-scroll-container">
                    <div class="x-inner x-panel-inner x-scroll-scroller" id="ext-element-6">
                        <div class="x-container" id="ext-container-1">
                            <div class="x-inner" id="ext-element-7">
                                <div class="x-container" id="ext-container-2">
                                    <div class="x-inner" id="ext-element-8">
                                        <div class="x-innerhtml " id="ext-element-9">
                                            <div class="rounded-div"><h1>RockPointe Church</h1><i>One church meeting in
                                                multiple locations.</i></div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="x-container" id="ext-container-3">
                            <div class="x-inner x-layout-hbox" id="ext-element-10"
                                 style="-webkit-box-align: stretch; -webkit-box-pack: center; ">
                                <div id="ext-button-1" class="x-button x-button-rpc x-button-plain x-layout-box-item"
                                     style="margin-top: 5px; -webkit-box-flex: 1; "><span style="display: none; "
                                                                                          id="ext-element-11"
                                                                                          class="x-badge"></span><span
                                        class="x-button-icon" style="display: none; " id="ext-element-13"></span><span
                                        style="" id="ext-element-12" class="x-button-label">Videos</span></div>
                                <div class="x-container x-button-rpc-spacer" id="ext-container-4"
                                     style="margin-top: 5px;">
                                    <div class="x-inner" id="ext-element-14"></div>
                                </div>
                                <div class="x-button x-button-rpc x-button-plain x-layout-box-item" id="ext-button-2"
                                     style="margin-top: 5px; -webkit-box-flex: 1; "><span style="display: none; "
                                                                                          class="x-badge"></span><span
                                        class="x-button-icon" style="display: none; "></span><span style=""
                                                                                                   class="x-button-label"
                                                                                                   id="ext-element-15">Events</span>
                                </div>
                                <div class="x-container x-button-rpc-spacer" id="ext-container-5"
                                     style="margin-top: 5px;">
                                    <div class="x-inner" id="ext-element-16"></div>
                                </div>
                                <div class="x-button x-button-rpc x-button-plain x-layout-box-item" id="ext-button-3"
                                     style="margin-top: 5px; -webkit-box-flex: 1; "><span style="display: none; "
                                                                                          class="x-badge"></span><span
                                        class="x-button-icon" style="display: none; "></span><span style=""
                                                                                                   class="x-button-label"
                                                                                                   id="ext-element-17">Sites</span>
                                </div>
                            </div>
                        </div>
                        <div class="x-size-change-detector x-size-change-detector-expand">
                            <div></div>
                        </div>
                        <div class="x-size-change-detector x-size-change-detector-shrink">
                            <div></div>
                        </div>
                    </div>
                    <div class="x-size-change-detector x-size-change-detector-expand">
                        <div></div>
                    </div>
                    <div class="x-size-change-detector x-size-change-detector-shrink">
                        <div></div>
                    </div>
                </div>
            </div>
        </div>
        <div class="x-container x-layout-card-item" id="ext-container-6" style="display: none !important; ">
            <div class="x-inner" id="ext-element-32"></div>
        </div>
        <div class="x-container x-layout-card-item" id="ext-container-7" style="display: none !important; ">
            <div class="x-inner" id="ext-element-35"></div>
        </div>
        <div class="x-container x-layout-card-item" id="ext-container-8" style="display: none !important; ">
            <div class="x-inner" id="ext-element-38"></div>
        </div>
        <div class="x-container x-layout-card-item" id="ext-container-9" style="display: none !important; ">
            <div class="x-inner" id="ext-element-41"></div>
        </div>
    </div>
</div>

2 个答案:

答案 0 :(得分:0)

我打赌问题是宽度:100%你有。这意味着它将使用容器div的100%大小,这与屏幕一样宽。添加5 px边距加上你拥有的任何填充或边框,你最终会在屏幕之外。

有道理吗?

答案 1 :(得分:0)

哇,出于某种原因,当我看到简单的解决方案时,我的大脑就会关闭。 :(

#rpc-view-home-indexview{
    padding: 5px;
}