简体   繁体   English

我怎样才能水平放置struts 2元素?

[英]How i can put struts 2 elements horizontally?

I'm working with Struts 2 + JqueryUI Struts2 Plugin and I want to put some items next to each other horizontally. 我正在使用Struts 2 + JqueryUI Struts2插件,我想水平放置一些项目。

In struts2 form item all the elements are vertical ... 在struts2表单项中,所有元素都是垂直...

This is my code: 这是我的代码:

<s:form action="test" theme="simple">
<sj:a id="ajaxlink" onclick="disminuyeBloque()" button="true" buttonIcon="ui-icon-minus" cssStyle="height:20px"/>
<sj:textfield id="tamannobloque"  name="tamannobloque" readonly="true" size="2" />
<sj:a id="ajaxlinkminus" onclick="aumentaBloque()" button="true" buttonIcon="ui-icon-plus" cssStyle="height:20px"/>
<sj:slider id="echo4" name="slider" label="Echo" value="{3, 7}" min="1" max="10" onCompleteTopics="sliderRangeStop" cssStyle="margin: 10px; width:20%"/>
</s:form>

I want the slider appears next the last button (a plus button) 我希望滑块出现在最后一个按钮(加号按钮)的旁边

If you want to print the slider inline you need to use the display:inline-block property and give the slider a certain width. 如果要内联打印滑块,则需要使用display:inline-block属性,并给滑块指定一定的宽度。

In your CSS: 在您的CSS中:

#echo4 {
    display: inline-block;
    width: 100px;
}

You can see a demo here . 您可以在此处查看演示。

You can try to set the form element's parentTheme to css_xhtml and wrap elements on the same line with div and apply your style afterwards. 您可以尝试将表单元素的parentThemecss_xhtml并使用div将元素包装在同一行上,然后再应用样式。

something like 就像是

<s:form action="test" theme="simple">
<div>
<sj:a id="ajaxlink" onclick="disminuyeBloque()" button="true" buttonIcon="ui-icon-minus" cssStyle="height:20px"/>
<sj:textfield id="tamannobloque"  name="tamannobloque" readonly="true" size="2" parentTheme="css_xhtml"/>
</div>
<div>
<sj:a id="ajaxlinkminus" onclick="aumentaBloque()" button="true" buttonIcon="ui-icon-plus" cssStyle="height:20px"/>
<sj:slider id="echo4" name="slider" label="Echo" value="{3, 7}" min="1" max="10" onCompleteTopics="sliderRangeStop" cssStyle="margin: 10px; width:20%" parentTheme="css_xhtml"/>
</div>
</s:form>

You can set the display property of the slider to inline , 您可以将滑块的显示属性设置为inline,

<style>
#echo4    
{
display:inline;
}
</style>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM