从此页面借来的解决方案: https://webdesign.tutsplus.com/tutorials/building-responsive-forms-with-flexbox--cms-26767
我在列表中有一个按钮:
<form>
<ul>
<li>
<a href="account.html" class="button">
<button type="submit">Submit</button>
</a>
</li>
</ul>
</form>
我尝试使用此代码:
<form action="account.html">
<button type="submit">Submit</button>
</form>
但这两种方法都不起作用。我的代码可以将按钮链接到account.html页面吗?
CSS代码:
a.button
{
margin: auto;
padding: 8px 16px;
border: none;
background: #333;
color: #f2f2f2;
text-transform: uppercase;
letter-spacing: .09em;
border-radius: 2px;
margin-top: 2%;
font-size: 1.5vw;
text-decoration: none;
}
答案 0 :(得分:1)
HMTL:
<ul>
<li>
<a href="account.html" class="button">Submit</a>
</li>
</ul>
CSS:
a.button {
margin: auto;
padding: 8px 16px;
border: none;
background: #333;
color: #f2f2f2;
text-transform: uppercase;
letter-spacing: .09em;
border-radius: 2px;
margin-top: 2%;
font-size: 1.5vw;
text-decoration: none;
}
修改强>
HTML:
<form action="account.html" method="GET">
<!-- Other fields -->
<ul>
<li>
<input type="submit" class="button" value="Submit">
<!-- or -->
<button type="submit" class="button">Submit</button>
</li>
</ul>
</form>
CSS:
input.button {
/* Your styles go here */
}
/* or */
button.button {
/* Your styles go here */
}
答案 1 :(得分:0)
第二个应该工作。但是,您可以跳转到输入而不是按钮。
<form action="account.html">
<input type="submit" value="Submit">
</form>