H5写搜索框:将搜索图标放入搜索框之内

最近在模仿写新浪微博的首页,其中搜索框的搜索按钮位于搜索框之内,突然想起刚刚接触前端的时候被这个给难住了,哎......实在是惭愧啊!

思想很简单:将input(type=text)和input(type=button)放入同一个div中,给这个div一个边框border,而input(type=text)不设置边框,这样就达到了效果。

代码如下:

.search {
  width: 568px;
  height: 28px;
  border: 1px solid #ccc;//设置边框
  background-color: #f2f2f5;
  margin: 10px 0;
}
.search_input {
  width: 520px;
  float: left;
  height: 28px;
  line-height: 28px \9;
  padding: 0 8px;
}
.search_btn {
  width: 18px;
  height: 26px;
  background: url(../img/s.jpg) left center no-repeat;
  float: right;
  margin-right: 10px;
}

 

你可能感兴趣的:(HTML/CSS/JS)