我有这个HTML代码:
<div id="welcomename">
<h1>Welcome! What's your name?</h1>
<input type="text" class="form" name="name" placeholder="Your name here!" id="name"/>
<input type="button" onclick="clicked();" value="I'm ready!"/>
</div>
<br>
这非常完美,但出于原因,我需要<br>
内的div 'welcomename
。但是,当我这样做时,它不起作用。
其他代码:
<div id="hiddenDiv" style="display: none;">
<h1 id="welcomehowareyou">How are you today, ?</h1>
<form id="welcomehowareyou2" method="post">
<select name="mood" onchange="popup(this.options.selectedIndex)">
<option value="" disabled selected>How are you?</option>
<option>I'm doing great, thanks!</option>
<option>I'm fine, but could be better</option>
<option>I feel absolutely terrible today.</option>
<!--<input type="submit" value="Done!"/>-->
</form>
<p></p>
</div>
答案 0 :(得分:4)
您正在添加&#34; br&#34;就在关闭div之前和输入元素之后吧?这是因为input元素是一个内联元素。
答案 1 :(得分:1)
请在此处查看小提琴 - http://jsfiddle.net/ghxce8dr/
它工作正常。我为这两个div添加了<p></p>
。
<div id="welcomename">
<h1>Welcome! What's your name?</h1>
<input type="text" class="form" name="name" placeholder="Your name here!" id="name"/>
<input type="button" onclick="clicked();" value="I'm ready!"/>
</div>
<p></p>
Text After First Break
<div id="hiddenDiv">
<h1 id="welcomehowareyou">How are you today, ?</h1>
<select name="mood" onchange="popup(this.options.selectedIndex)">
<option value="" disabled selected>How are you?</option>
<option>I'm doing great, thanks!</option>
<option>I'm fine, but could be better</option>
<option>I feel absolutely terrible today.</option></select>
<!--<input type="submit" value="Done!"/>-->
<p></p>
Text After Second Break
</div>
希望这会对你有所帮助。