如何在不使用theme =“simple”的情况下使用Struts2在同一行中定位多个文本字段? [英] How to position multiple text fields in same line using Struts2 without using theme="simple"?
问题描述
我想设计一个网页,使用struts2在同一行显示用户标识和密码。
如何管理它而不使用 theme ='simple'
?
<%@ taglib uri =/ struts-tagsprefix =s%>
<%@ page contentType =text / htmlpageEncoding =UTF-8%>< html>
< head>
< / head>
< body>
< s:form action =Register.action>
< s:password name =passlabel =Password/>
< / s:form>
< / div>
源代码:
<!DOCTYPE html>
< html>
< head>
< / head>
< body>
< form id =Registeraction =Register.actionmethod =post>
< table class =wwFormTable>
< tr>
< td class =tdLabel>
< label for =Register_uidclass =label>使用者名称:< / label>
< / td>
< td>
< input type =textname =uidvalue =id =Register_uid/>
< / td>
< / tr>
< tr>
< td class =tdLabel>
< label for =Register_passclass =label>密码:< / label>
< / td>
< td>
< input type =passwordname =passid =Register_pass/>
< / td>
< / tr>
< / table>
< / form>
< / body>
< / html>
默认情况下,Struts2正在使用 xhtml
主题,它使用表格布局封装输入字段。表格布局利用其元素的独特定位,使用行和列。你不能在同一行显示两行。
另一方面,有一个主题 css_xhtml
正在使用
标准的两列基于CSS的布局,用于HTML Struts标记(表单,文本字段,选择等)
您可以更改内联元素的样式。如果为textfild生成了 div
s,那么您可以使用样式 dysplay:inline-block
inline-block Value
长时间以来,可以创建一个填充浏览器宽度并很好地包装(当浏览器为
调整大小时)的框格,通过使用float
属性。
然而,
inline-block
$显示
属性的值使得这个
更容易。
嵌入块元素是像内嵌元素,但它们可以有
宽度和高度。
代码:
< style>
。浮动框{
display:inline-block;
}
< / style>
< / s:form>
I want to design a webpage that display the user id and password in same line using struts2.
How to manage it without using theme='simple'
?
<%@taglib uri="/struts-tags" prefix="s" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%><html>
<head>
</head>
<body>
<s:form action="Register.action">
<s:textfield name="uid" label="User Name"/>
<s:password name="pass" label="Password"/>
</s:form>
</div>
Source Code of the above:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form id="Register" action="Register.action" method="post">
<table class="wwFormTable">
<tr>
<td class="tdLabel">
<label for="Register_uid" class="label">User Name:</label>
</td>
<td>
<input type="text" name="uid" value="" id="Register_uid"/>
</td>
</tr>
<tr>
<td class="tdLabel">
<label for="Register_pass" class="label">Password:</label>
</td>
<td>
<input type="password" name="pass" id="Register_pass"/>
</td>
</tr>
</table>
</form>
</body>
</html>
By default Struts2 is using xhtml
theme, that wraps input fields with the table layout. A table layout utilizes unique positioning of its elements, using rows and columns. You can't display two rows on the same line.
On the other hand there's a theme css_xhtml
that is using
Standard two-column CSS-based layout, using for the HTML Struts Tags (form, textfield, select, etc)
you can change the style of elements to display inline. If div
s are generated for textfilds them you can use a style dysplay: inline-block
The inline-block Value
It has been possible for a long time to create a grid of boxes that fills the browser width and wraps nicely (when the browser is resized), by using thefloat
property.However, the
inline-block
value of thedisplay
property makes this even easier.inline-block elements are like inline elements but they can have a width and a height.
The code:
<style>
.floating-box {
display: inline-block;
}
</style>
<s:form action="Register.action" theme="css_xhtml">
<s:textfield name="uid" label="User Name" cssClass="floating-box"/>
<s:password name="pass" label="Password" cssClass="floating-box"/>
</s:form>
这篇关于如何在不使用theme =“simple”的情况下使用Struts2在同一行中定位多个文本字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!