nut*_*les 3 html css jsp spring-mvc
我正在使用Spring MVC <form:radiobuttons>来显示单选按钮:
<form:radiobuttons path="selection" items="${arraySelection}" />
Run Code Online (Sandbox Code Playgroud)
但是,它会水平显示它们.生成的HTML如下:
<span>
<input id="selection1" type="radio" value="0"" name="selection">
<label for"selection1">Off</label>
</span>
<span>
<input id="selection2" type="radio" value="1"" name="selection">
<label for"selection2">On</label>
</span>
Run Code Online (Sandbox Code Playgroud)
如何垂直显示它们?
您可以将默认包装器(即<span>)更改为可以更好地操作的其他包装<li>,例如.
您可以使用该element属性更改包装器:
<ul>
<form:radiobuttons path="selection" items="${arraySelection}" element="li" />
</ul>
Run Code Online (Sandbox Code Playgroud)
那么只需要按照你想要的方式设计:
ul.verticalRadios {
list-style-type: none;
/* or whatever */
}
...
<ul class="verticalRadios">
<form:radiobuttons path="selection" items="${arraySelection}" element="li" />
</ul>
Run Code Online (Sandbox Code Playgroud)