为什么这个 DIV 看起来不一样?
第一:
<div data-role="fieldcontain">
<fieldset data-role="controlgroup">
<legend>City</legend>
<input type="text" id="select_team_city" value="" placeholder="Type Team City"/>
</fieldset>
</div>
第二:
<div data-role="fieldcontain">
<label for="select_team_name">Name</label>
<input type="text" id="select_team_name" value="" placeholder="Type Team Name"/>
</div>
最佳答案
嗯,不知道我理解是否正确。它们看起来不同,因为图例的作用与标签不同
根据 w3c,图例将相关元素分组到表单(例如多个字段)
http://www.w3schools.com/tags/tag_legend.asp
而 label 定义输入元素的标签
http://www.w3schools.com/tags/tag_label.asp
请参阅此处的示例,或考虑以下内容。 我不确定您想要实现什么目的,但以下是我如何理解这些标签的用法:
<div data-role="fieldcontain">
<fieldset data-role="controlgroup">
<legend>Team Information</legend>
<label for="select_team_city">City</label>
<input type="text" id="select_team_city" value="" placeholder="Type Team City"/>
<label for="select_team_name">Name</label>
<input type="text" id="select_team_name" value="" placeholder="Type Team Name"/>
</fieldset>
</div>
请参阅此处的工作示例: http://jsfiddle.net/C3CR2/2/
关于Jquery mobile <fieldset data-role ="controlgroup"> 使控件收缩,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13520479/