33
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

posted at

updated at

【HTML】CSSによる検索フォームのデザイン

デフォルトのデザイン

form00.PNG

HTML
<form action="#">
    <input type="text">
    <input type="submit">
</form>

一体型

form01.PNG

HTML
<form id="form01" action="#">
    <input id="input01" type="text"><!--
    /input間で改行したい場合はコメントアウト必須/
    --><input id="submit01" type="submit" value="検索">
</form>
CSS
#form01{
    background-color: white;
    width:200px;
    height: 20px;
    border: 1px green solid;
}
#form01 input{
    vertical-align: top;
    margin: 0px;
    height: 100%;
    box-sizing: border-box;
    background-color: transparent;
}
#input01{
    width: 150px;
    border: none;
    border-right: 1px green solid;
}
#submit01{
    width: 50px;
    border: none;
}

一体型(画像ボタンによるsubmit)

form03.PNG

HTML
<form id="form02" action="#">
    <input id="input02" type="text" placeholder="検索"><!--
    /input間で改行したい場合はコメントアウト必須/
    --><input id="submit02" type="submit" value="">
</form>
CSS
#form02{
    background-color: white;
    width:200px;
    height: 20px;
    border: 1px green solid;
}
#form02 input{
    vertical-align: top;
    margin: 0px;
    height: 100%;
    box-sizing: border-box;
    background-color: transparent;
}
#form02{
    border-radius: 10px;
}
#input02{
    border: none;
    width: 170px;
    padding-left: 10px;
}
#submit02{
    width: 30px;
    border: none;
    background-image: url(画像へのパス);
    background-position: center;
    background-size: auto 90%;
    background-repeat: no-repeat;
}
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Sign upLogin
33
Help us understand the problem. What are the problem?