如何对齐两个提交按钮? [英] How to align two submit buttons?

查看:145
本文介绍了如何对齐两个提交按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<s:form action="download1" name="regform" id="formSelectOne"  theme="simple">
    <td  valign="top" align="right" >
        <s:submit value="View coc1  " theme="simple" />
    </td>
</s:form>

<s:form action="download2" name="regform" id="formSelectOne"  theme="simple">
    <td  valign="top" align="center">   
         <s:submit value="View doc2" theme="simple" />
    </td>  
</s:form>

这些按钮并排显示,但我需要显示右边的第一个,在中心。

The buttons are shown side by side, but I need to display the first on the right and the second on the center. How can I do ?

推荐答案

页面上没有必要提供两种表单来提交不同的操作(方法)。

It's not necessary to have two forms on the page to submit different actions (methods).

从一开始,Struts就有一种技巧来分配提交按钮到不同的操作。在最新版本中,它通过 submit 标签执行,用于从属性(例如 action 或方法

Since the beginning, Struts has a technique to dispatch submit buttons to different actions. In the latest version it's performed via the submit tag, that is used to build the action URL from the attributes such as action or method.

由于您在表单上使用简单主题标签,它继承到所有输入字段。没有必要单独应用相同的主题。

As you are using a simple theme on the form tag, it's inherited to all input fields. It's not necessary to apply the same theme individually.

如果您使用 table HTML标记来设计表单元素,记录 tr 标记具有 white-space:nowrap; CSS样式。例如

If you are using a table HTML tag to design your form elements it's substantial to put these buttons inside the same record tr tag having white-space:nowrap; CSS style. For example

<s:form  name="regform" id="regform" theme="simple">
<table style="width:100%;" cellspacing="0" cellpadding="0" border="0">
  <tr style="white-space:nowrap;">
    <td style="width:50%;" valign="top" align="right" >
        <s:submit action="download2" value="View coc2"/>
    </td>
    <td style="width:50%;" valign="top" align="right" >
        <s:submit action="download1" value="View coc1"/>
    </td>
  </tr>
<table>
</s:form>

要使操作 this 答案,了解如何在 struts.xml中启用操作前缀能够使用 s:submit 标签的 action 属性。

To have the action attribute being worked see this answer to learn how to enable an action prefix in struts.xml to be able to use action attribute of the s:submit tag.

这篇关于如何对齐两个提交按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆