カテゴリー: CSS

  • Contact Form 7 の見た目を綺麗にする HTML CSS コピペOK

    Contact Form 7 の見た目を綺麗にする HTML CSS コピペOK

    これは何?

    WordPressの定番のお問い合わせ用プラグインのcontact form 7 のCSSを編集しました。

    実装すると以下のようになります。

    focus に少しease を入れるのがこだわり

    コンタクトフォーム7にスタイルを適応する方法

    プラグインからcontact form 7を新規追加します。

    インストールして有効化すると左サイドバーに Contact という項目ができていると思うので、クリックします。

    開くと、すでに追加されているフォームがあると思いますので、
    そちらを開きます。

    開いたら、編集画面になりますので以下のコードを貼り付けます(コピペOK)

    コードは contact form 7 の公式サイトを頼りにクラスなどの指定をしました。
    なるべくインストール時の標準の状態を崩さずにスタイリングしています。

    <label class="form__label"> 企業名
        [text* your-name class:form__textInput autocomplete:name] </label>
    
    <label class="form__label"> お名前
        [text* your-name class:form__textInput autocomplete:name] </label>
    
    <label class="form__label"> メールアドレス
        [email* your-email class:form__textInput autocomplete:email] </label>
    
    
    <label class="form__label"> お問い合わせ内容
        [textarea* your-message class:form__textInput] </label>
    
    [submit "Submit"]
    
    <style>
    .form__container {
      max-width: 400px;
      margin:0 auto;
    }
    
    .form__label {
      display: block;
      margin-top:1.5em;
      color: gray;
      font-size: 0.8em;
    }
    
    
    
    .form__textInput {
      width: calc(100% - 2.4em);
      border: 1px #c0c0c0 solid;
      border-radius: 2px;
      padding: 1em 1.2em;
      color: 1e1e1f;
    }
    
    .form__textInput:focus {
      transition: .3s ease-out;
      outline: 1px skyblue solid;
    }
    
    .wpcf7-submit {
      display: block;
      color: white;
      background-color: black;
      padding: 0.8em 2em;
      border-radius: 4px;
      margin: 2em auto;
      border: none;
    }
    
    .wpcf7-submit:active {
      background-color: rgb(95, 95, 95);
      /* This style is created by https://coiai.net */
    }
    </style>

    フォームの入力が完了したら、固定ページに移動して追加しました。

    次の画像のような感じで追加しています。

    コード自体にはタイトルや背景色指定、サイズ制限などの余計なことはなるべくしないようにしました。お使いの場合は適宜環境に合わせてお使いください。

  • HTML, CSS のみでタイムラインを作りたい スマホ対応

    HTML, CSS のみでタイムラインを作りたい スマホ対応

    これは何?

    HTML, CSS のみで単純なタイムラインのスタイルを作成するコードの紹介です。

    カラミーショップや制限のあるWordrpress などでピュアなHTML, CSS で実装しなければならない場合に使えると思います。

    スマホ対応にもしています。よければお使いください。

    コードの紹介

    以下のコードで実装すると次のような見た目のものが実装できます。
    最低限のスタイルですので適宜いじっていただければと思います。

    <!DOCTYPE html>
    <html lang="ja">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>timeline</title>
      <link rel="stylesheet" href="./style.css">
    </head>
    <body>
      <div class="container">
        <!-- item box LEFT ここを繰り返す -->
        <div class="timeline__container">
          <div class="timeline__textBox">
            <div class="timeline__textBox__text left">
              text
            </div>
          </div>
          <div class="timeline__line">
            <div class="timeline__dot"></div>
          </div>
          <div class="timeline__date">
            2024
          </div>
        </div>
        <!-- item box 終わり -->
    
        <!-- item box RIGHT ここを繰り返す -->
        <div class="timeline__container">
    
          <div class="timeline__date left">
            2024
          </div>
          
          <div class="timeline__line">
            <div class="timeline__dot"></div>
          </div>
    
          <div class="timeline__textBox">
            <div class="timeline__textBox__text right">
              text
            </div>
          </div>
        </div>
        <!-- item box 終わり -->
    
        <!-- item box  LEFT ここを繰り返す -->
        <div class="timeline__container">
          <div class="timeline__textBox">
            <div class="timeline__textBox__text left">
              text
            </div>
          </div>
          <div class="timeline__line">
            <div class="timeline__dot"></div>
          </div>
          <div class="timeline__date">
            2024
          </div>
        </div>
        <!-- item box 終わり -->
    
        <!-- item box LEFT ここを繰り返す -->
        <div class="timeline__container">
          <div class="timeline__textBox">
            <div class="timeline__textBox__text left">
              text
            </div>
          </div>
          <div class="timeline__line">
            <div class="timeline__dot"></div>
          </div>
          <div class="timeline__date">
            2024
          </div>
        </div>
        <!-- item box 終わり -->
      </div>
    </body>
    </html>
    .timeline__container {
      display: grid;
      grid-template-columns: 1fr 150px 1fr;
      grid-template-rows: 1fr;
    }
    
    .timeline__textBox {
    }
    
    .left {
      margin-left: auto;
    }
    
    .right {
      margin-right: auto;
    }
    
    .timeline__textBox__text {
      background-color: rgb(224, 231, 233);
      max-width: 370px;
      padding: 32px;
      border-radius: 16px;
      margin-top: 8px;
      margin-bottom: 8px;
    }
    
    .timeline__line {
      height: 100%;
      display: flex;
      justify-content: center;
      position: relative;
    }
    
    .timeline__line::after {
      content: '';
      background-color: rgb(72, 176, 255);
      width: 4px;
      height: 100%;
    }
    
    .timeline__dot {
      width: 16px;
      height: 16px;
      background-color: rgb(72, 176, 255);
      border-radius: 999px;
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
    }
    
    .timeline__date {
      display: flex;
      align-items: center;
      color: gray;
      font-style: italic;
    }
    
    /* スマホ版のスタイル */
    @media (max-width: 768px) {
      .timeline__container {
        grid-template-columns: 100px 70px 1fr;
      }
    
      .timeline__textBox {
        grid-column: 3 / 4;
        grid-row: 1 / 2;
      }
    
      .timeline__date {
        grid-column: 1 / 2;
        grid-row: 1 / 2;
      }
    
      .timeline__line {
        grid-column: 2 / 3;
        grid-row: 1 / 2;
      }
    
      .left, .right {
        margin-left: 0;
        margin-right: 0;
      }
    }
Home
About
Blog
Works
Contact