亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

搜索框和搜索按鈕不平怎么辦?改height,margin都沒用?咋整?

搜索框和搜索按鈕不平怎么辦?改height,margin都沒用?咋整?

滄海一幻覺 2022-07-07 14:10:31
html:<html><body><div class="search"> <form method="get" action="#"> <input type="text" value="####" onfocus="if(this.value=='####')this.value='';" onblur="if(this.value=='')this.value='####';"></input> <input type="submit" value="搜 索"></input> </form> </div></body></html>css:.header .search input[type="text"]{ width:450px; height:35px; padding-left:8px; color:#999; border:2px solid #ffaa00;} .header .search input[type="submit"]{ width:90px; height:35px; background:#ffaa00; text-align:center; line-height:16px; color:#fff; font-family:微軟雅黑; font-weight:700; font-size:16px; cursor:pointer; border:none; margin-left:-8px;}效果:
查看完整描述

2 回答

?
翻過高山走不出你

TA貢獻1875條經驗 獲得超3個贊

一般我們都會對css做一些初始化的設置,特別是塊級元素padding margin值設為0;


<!doctype html><html><head><meta charset="utf-8"><title>無標題文檔</title></head><style type="text/css">input { margin: 0; padding: 0;}.search input[type="text"] { width: 450px; height: 35px; padding-left: 8px; color: #999; border: 0; outline: 0;}.search input[type="submit"] { width: 90px; height: 39px; background: #ffaa00; text-align: center; line-height: 16px; color: #fff; font-family: 微軟雅黑; font-weight: 700; font-size: 16px; cursor: pointer; border: none; margin-left: -8px;}.form-group { float: left; border: 2px solid #ffaa00;}</style><body><div class="search">  <form method="get" action="#">    <div class="form-group">      <input type="text" value="####" onfocus="if(this.value=='####')this.value='';" onblur="if(this.value=='')this.value='####';">    </div>    <input type="submit" value="搜 索">  </form></div></body></html>




查看完整回答
反對 回復 2022-07-11
?
慕的地6264312

TA貢獻1817條經驗 獲得超6個贊

輸入框跟搜索的高度并不一樣。
height是39但是,一個加上4像素的上下邊框,一個沒有。
所以得在,submit修改,border:2px solid #ffaa00;
另外垂直對齊的方式也得添加上,text和submit都添加vertical-align:middle;

查看完整回答
反對 回復 2022-07-11
  • 2 回答
  • 0 關注
  • 208 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號