【发布时间】:2016-11-18 13:32:55
【问题描述】:
我的 HTML 和 CSS 在这里。我从流行的网站 w3schools.com 获得了此代码。我必须在哪里写什么?
<html>
<head>
<style>
input[type=text] {
width: 130px;
box-sizing: border-box;
border: 2px solid #ccc;
border-radius: 4px;
font-size: 16px;
background-color: white;
background-image: url('searchicon.png');
background-position: 10px 10px;
background-repeat: no-repeat;
padding: 12px 20px 12px 40px;
-webkit-transition: width 0.4s ease-in-out;
transition: width 0.4s ease-in-out;
}
input[type=text]:focus {
width: 100%;
}
</style>
</head>
<body>
<p>Animated search form:</p>
<form>
<input type="text" name="search" placeholder="Search..">
</form>
</body>
</html>
谢谢
【问题讨论】:
-
您的
<form>标签需要知道要搜索什么,通过使用method和action属性。 -
@Lee — 这是一个搜索表单,所以一个 GET 请求就可以了,所以不需要方法属性,因为 GET 是默认的。
-
@Lee — action 属性也是可选的,如果省略,它将默认为当前页面的 URL,这通常是可取的。
-
需要添加功能码