Sencha Touch:将按钮与面板右侧和文本中心水平对齐
我想要一个面板,其中唯一的按钮靠右对齐。我知道“间隔”的概念。但另外我想水平设置一个 html 文本中心。但使用“间隔”并没有真正起作用。文本并不是真正位于面板的中间。 “spacer”是如何工作的,我怎样才能达到我想要的效果?
js 代码:
this.topPanel = new Ext.Panel({
layout: 'hbox',
height: 50,
cls: 'topPanelCls',
items: [
{xtype: 'spacer'},
{html: 'TextText', width: 100, height: 30},
{xtype: 'spacer'},
this.forwardButton
]
});
“forwardButton”的样式:
.forwardButtonCls {
background: #ccc;
color: #ffffff;
font-size: 14px;
border: none;
vertical-align: center; }
topPanel 的样式:
.topPanelCls {
margin: 10px 0px 0px 0px; }
.topPanelCls .x-panel-body {
background-color: #fff !important;
background-image: none !important;
width: 700px;
border:4px solid #ccc; }
知道如何解决我的问题吗?
I want to have a panel with the only button aligned to the right. I know the idea of 'spacer'. But additionally I want to set a html text center horizontally. But using 'spacer' it doesn't really work. The text is not really in the midst of the panel. How does 'spacer' work, and how can I achieve what I want?
js-code:
this.topPanel = new Ext.Panel({
layout: 'hbox',
height: 50,
cls: 'topPanelCls',
items: [
{xtype: 'spacer'},
{html: 'TextText', width: 100, height: 30},
{xtype: 'spacer'},
this.forwardButton
]
});
Style of 'forwardButton':
.forwardButtonCls {
background: #ccc;
color: #ffffff;
font-size: 14px;
border: none;
vertical-align: center; }
Style of topPanel:
.topPanelCls {
margin: 10px 0px 0px 0px; }
.topPanelCls .x-panel-body {
background-color: #fff !important;
background-image: none !important;
width: 700px;
border:4px solid #ccc; }
Any idea how I can solve my problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我也遇到过类似的问题。我想在左侧有一个后退按钮,在中间有一个分段按钮。我所做的是将后退按钮的 Flex 属性设置为 1,效果很好。分段按钮现在以我为中心。希望这对您的问题有所帮助。
I have had a similar problem. I wanted to have a back button to the left, and a segmented button centered. What I have done is to set the backbutton flex attribute to 1 and it worked well. segmentedbutton is now centered for me. Hope this helps for your problem.