お問合せフォームのデザイン(1)

とても便利な、国産のお問合せフォームのプラグイン「Contact Form 7」

cssが苦手なため、なかなか使いこなせなかったので、まとめておきます。
理想形は「カスタマイズ」のデザインなので、これを定番にしよう。

フォームのデザイン

まずは、フォームを新規作成します。
作りたいのはこんなデザインのフォーム。
CSSを追記したあと、フォームのhtmlに項目を追記しながら、作っていきます

出力結果

    必須お名前

    必須メールアドレス

    任意電話番号

    必須ご住所

    必須お問い合わせ内容

    必須お問い合わせ内容

      ◆◆◆宜しければアンケートにもご記入ください◆◆◆

    任意ご家族は何人ですか?

    任意いつ頃までにご予定ですか?

    任意不安がありますか?

    任意当サイトの情報に興味はありますか?

    任意勉強会やイベントの案内をご希望されますか?

    このサイトはreCAPTCHAによって保護されています。Googleのプライバシーポリシー利用規約が適用されます。

    CSSに追記
    /*******お問合せフォーム*********/
    input[type="text"],
    input[type="password"],
    input[type="datetime"],
    input[type="date"],
    input[type="month"],
    input[type="time"],
    input[type="week"],
    input[type="number"],
    input[type="email"],
    input[type="url"],
    input[type="search"],
    input[type="tel"],
    input[type="color"],
    select,
    textarea,
    .field {
      display: block;
      width: 100%;
      height: 45px;
      margin-bottom: 0;
      padding: 0 12px;
      border: 0;
      border-radius: 3px;
      background-color: #eff1f5;
      box-shadow: none;
      color: #5c6b80;
      font-size: 1em;
      vertical-align: middle;
      line-height: 45px;
      transition: background-color 0.24s ease-in-out;
    }
    textarea {
      max-width: 100%;
      min-height: 120px;
      line-height: 1.5em;
      padding: 0.5em;
      overflow: auto;
    }
    @media(max-width:500px) {
        .inquiry td,
        .inquiry th {
            display: block !important;
            width: 100% !important;
            border-top: none !important;
            -webkit-box-sizing: border-box !important;
            -moz-box-sizing: border-box !important;
            box-sizing: border-box !important
        }
        .inquiry tr:first-child th {
            border-top: 1px solid #d7d7d7 !important
        }
        .inquiry .nini,
        .inquiry .hissu {
            font-size: 10px
        }
    }
    .inquiry th {
        text-align: left;
        font-size: 14px;
        color: #444;
        padding-right: 5px;
        width: 40%;
        background: #f7f7f7;
        border: solid 1px #d7d7d7
    }
    .inquiry td {
        font-size: 13px;
        border: solid 1px #d7d7d7
    }
    .entry-content .inquiry tr,
    .entry-content table {
        border: solid 1px #d7d7d7
    }
    .hissu {
        font-size: 7px;
        padding: 5px;
        background: #f29c9f;
        color: #fff;
        border-radius: 2px;
        margin-right: 5px;
        position: relative;
        bottom: 1px
    }
    .nini {
        font-size: 7px;
        padding: 5px;
        background: #84ccc9;
        color: #fff;
        border-radius: 2px;
        margin-right: 5px;
        position: relative;
        bottom: 1px
    }
    .verticallist .wpcf7-list-item {
        display: block
    }
    #formbtn {
        display: block;
        padding: 15px;
        width: 550px;
        background: #7073d2;
        color: #fff;
        font-size: 18px;
        font-weight: 700;
        border-radius: 2px;
        margin: 25px auto 0
    }
    #formbtn:hover {
        background: #fff;
        color: #7073d2;
        border: 2px solid #7073d2
    }
    th {
        font-weight: 700;
        text-transform: uppercase;
        padding: 13px
    }
    td {
        border-top: 1px solid #ededed;
        padding: 12px
    }
    input,
    select,
    textarea {
        border: 1px solid #dfdfdf;
        letter-spacing: 1px;
        margin: 0;
        max-width: 100%;
        resize: none
    }
    フォームのhtml
    <table class="inquiry">
    <tr>
    <th ><span class="hissu">必須</span><span>お名前</span></th>
    <td>[text* your-name class:textsp placeholder"鈴木 花子"]</td>
    </tr>
    <tr>
    <th><span class="hissu">必須</span><span>メールアドレス</span></th>
    <td>[email* your-email class:mailsp placeholder"xxxxx@gmail.com"]</td>
    </tr>
    <tr>
    <th><span class="nini">任意</span><span>電話番号</span></th>
    <td>[tel your-tel class:tel placeholder"090-0000-0000"]</td>
    </tr>
    <tr>
    <th><span class="hissu">必須</span><span>ご住所</span></th>
    <td>[radio adress use_label_element default:1 "東京23区内" "東京23区外" "埼玉県" "神奈川県" "千葉県" "その他"]</td>
    </tr>
    <tr>
    <th><span class="hissu">必須</span><span>お問い合わせ内容</span></th>
    <td>[select* contact-menu include_blank  "セミナー参加希望" "資料送付希望" "メルマガ登録" "相談したい" "その他"]</td>
    </tr>
    <tr>
    <th><span class="hissu">必須</span><span>お問い合わせ内容</span></th>
    <td>[textarea* your-message class:content placeholder "具体的なお問い合わせ内容をご記入ください"]</td>
    </tr>
    <tr>
    <th colspan="2"><span>  ◆◆◆宜しければアンケートにもご記入ください◆◆◆</span></th>
    </tr>
    <tr>
    <th><span class="nini">任意</span><span>ご家族は何人ですか?</span></th>
    <td>[radio Q1 use_label_element default:none "無回答" "1人" "2人" "3人" "4人" "5人" "それ以上"]</td>
    </tr>
    <tr>
    <th><span class="nini">任意</span><span>いつ頃までにご予定ですか?</span></th>
    <td>[radio Q2 use_label_element default:1 "なるべく早く" "数カ月以内" "年内" "1~2年以内" "今はまだ未定"]</td>
    </tr>
    <tr>
    <th><span class="nini">任意</span><span>不安がありますか? </span></th>
    <td>[radio Q4 use_label_element default:none "はい" "いいえ"]</td>
    </tr>
    <tr>
    <th><span class="nini">任意</span><span>当サイトの情報に興味はありますか?</span></th>
    <td>[radio Q5 use_label_element default:1 "はい" "いいえ"]</td>
    </tr>
    <tr>
    <th><span class="nini">任意</span><span>勉強会やイベントの案内をご希望されますか?</span></th>
    <td>[radio Q6 use_label_element default:1 "はい" "いいえ"]</td>
    </tr>
    </table>
    <br />
    <p><center>[acceptance accept-this-1 class:input2]確認画面は表示されませんのでご承ください。<br />
    送信後、自動返信メールが届いていることをご確認ください。 [/acceptance]</center></p> 
    
    <center>[submit id:formbtn "個人情報の取扱いについて同意し、上記の内容で送信する"]</center>
    <center><small>このサイトはreCAPTCHAによって保護されています。Googleの<a href = "https://policies.google.com/privacy">プライバシーポリシー</a>と<a href = "https://policies.google.com/terms">利用規約</a>が適用されます。</small></center>
    出力結果

      フォームhtml
      <label> 氏名
          [text* your-name] </label>
      
      <label> メールアドレス
          [email* your-email] </label>
      
      <label> 題名
          [text* your-subject] </label>
      
      <label> メッセージ本文 (任意)
          [textarea your-message] </label>
      
      [submit "送信"]

      フォームのデザインを整える

      テーブルのカスタマイズ

      テーブルタグをコピペして項目を増やす。<tr><th></th><td></td></tr>で1行。

      2つのセルを結合して1行にする場合は <th colspan=”2″> を使う。

      ポイント

      目的に応じて、フォームを追加

      フォームのテンプレートタグ

      テンプレートが用意されているので、簡単挿入。


      テキスト


      ドロップダウン

      項目を選択する。1行にまとまるので、選択肢の多いときにスッキリする

      ラジオボタン 

      どれかひとつのみ選択する時、ひと文が短いとき。

      チェックリスト  

      複数選択するとき。ひと文が短いときなど。


      承認確認


      送信ボタン


      出力結果

        いちごみかんバナナりんご

        いちごみかんばななりんご


        フォームの基本のタグ [_site_admin_email] サイトのログインに使用しているメールアドレス

        [_site_title] ホームページのタイトルが入ります

        [_site_url] ホームページのURL

        [your-subject] お問合せの件名

        [your-email] お問合せをしたお客様のメールアドレス

        [your-name]  お客様の名前

        [your-message]  お客様が入力した問い合わせ内容

        フォームを投稿や固定ページに挿入

        ブロックエディタに、コンタクトフォームのブロックが出現
        ここから、作成したフォームを選択します