【发布时间】:2021-12-09 07:59:18
【问题描述】:
所以我有一个作业,我们必须创建一个包含多个元素的表单。其中之一是复选框,选中后,结果页面中显示的链接应在新选项卡中打开。没有 Javascript,只有 html 和 css!
fieldset{
display: table;
}
p{
display: table-row;
}
label{
font-family: Arial;
padding: 10px;
display: table-cell;
}
input{
margin-left: 30px;
display: table-cell;
}
<form action="https://www.google.com/search">
<fieldset>
<!--Google search/field-->
<legend>Google search</legend>
<p>
<label for="search">Search</label>
<input id="search" name="q" type="text">
</p>
<!--Google search/slider-->
<p>
<label for="hits">Number of hits</label>
<input id="hits" type="range"
min="1" max="10" value="5"
oninput="rangeValue.innerText = this.value"
name="num">
</p>
<!--Google search/Checkbox-->
<p>
<label for="newTab">New Tab</label>
<input id="newTab" type="checkbox"
name="target" value="_blank">
</p>
<!--Start search-->
<input type="submit" value="Start search">
</fieldset>
</form>
At 是我尝试过的代码,但我无法让它工作。 抱歉,如果代码有点乱,我们现在才刚学习 html 一个月,而我才刚刚开始学习 :)
【问题讨论】: