标题出现在悬停输入文本上

时间:2015-02-06 11:06:43

标签: html css

我正在尝试制作一个输入文字以获得一个标题选项,就像你可以使用div一样...这可以做到这一点吗?

这是我尝试过的,但似乎它不起作用...... HTML:

<label>
   <input type="checkbox" class="promote_checkbox">Promote with</input>
   <input type="text" class="promote_points_number" maxLength="3" title="you need minimum 5 points to promote">Points</input>
</label>

此标签还有另一个问题:如果您尝试在文本框中输入内容,则无法选中该复选框...您能否告诉我为什么会这样?发生?

http://jsfiddle.net/2xw32q80/

2 个答案:

答案 0 :(得分:0)

在HTML中,<input>标记没有结束标记,而在XHTML中,必须正确关闭,例如<input />

<label>标记定义了<input>元素的标签,因此您需要使用自己的<input>标记封装每个<label>,如下所示:

&#13;
&#13;
<label>Label for checkbox
    <input type="checkbox" class="promote_checkbox">
</label>
<label>Label for points
    <input type="text" class="promote_points_number" maxLength="3" title="you need minimum 5 points to promote">
</label>
&#13;
&#13;
&#13;

OR每个for都有<label>个属性,与id

<input>属性相对应

&#13;
&#13;
<label for="box">Label for checkbox</label>
<input type="checkbox" id="box"><br>
<label for="points">Label for points</label>
<input type="text" id="points" maxLength="3" title="you need minimum 5 points to promote">
&#13;
&#13;
&#13;

答案 1 :(得分:-1)

观看您的标记,您没有关闭<input>标记!这在Opera中适用于我:

<label>
  <input type="checkbox" class="promote_checkbox" />Promote with
  <input type="text" class="promote_points_number" maxLength="3" title="you need minimum 5 points to promote" />Points
</label>

结果:

Text edit with title