「すぐにつくれて、ちょうどいい」WordPressテーマ SYN Ownd

2026年1月14日:アップデートのお知らせ、SYN Ownd 0.2.0 を公開しました

Contact Form 7 のスタイルを調整する例

フォームプラグイン「Contact Form 7」を利用した際、そのままではスタイルが適用されません。
SYNではプラグイン固有のCSSなどは、アップデートなどの変更に追従できないため採用していません。

フォームを設置するページにカスタムCSSを追加して、スタイルを整える例を挙げたいと思います。
ご利用の環境に合わせて調整してください。

カスタムCSSに追加

/* =========================================
   Contact Form 7 custom style
========================================= */

.wpcf7 {
  --cf7-text: #666;
  --cf7-muted: #666;
  --cf7-border: #dcdcdc;
  --cf7-border-focus: #999;
  --cf7-bg: #fff;
  --cf7-bg-soft: #f7f7f7;

  --cf7-danger: #d92c2c;
  --cf7-danger-bg: #fff5f5;
  --cf7-danger-border: #f0b8b8;

  --cf7-success-bg: #f3f8f4;
  --cf7-success-border: #b7d7bf;
  --cf7-success-text: #234b2c;

  --cf7-button-bg: #111;
  --cf7-button-text: #fff;

  --cf7-radius: 8px;
  --cf7-height: 48px;
  --cf7-font-size: 16px;
  --cf7-label-size: 14px;
  --cf7-space: 24px;
}

/* フォーム全体 */
.wpcf7 form {
  color: var(--cf7-text);
}

/* 各項目 */
.wpcf7 form > p {
  margin: 0 0 var(--cf7-space);
  line-height: 1.7;
}

/* ラベル */
.wpcf7 form label {
  display: block;
  font-size: var(--cf7-label-size);
  font-weight: 600;
  color: var(--cf7-text);
}

/* ラップ */
.wpcf7 .wpcf7-form-control-wrap {
  display: block;
  margin-top: 8px;
}

/* =========================
   入力系 共通
========================= */
.wpcf7 input[type="text"],
.wpcf7 input[type="email"],
.wpcf7 input[type="date"],
.wpcf7 input[type="tel"],
.wpcf7 input[type="url"],
.wpcf7 input[type="number"],
.wpcf7 select,
.wpcf7 textarea {
  width: 100%;
  max-width: 100%;
  font-size: var(--cf7-font-size);
  color: var(--cf7-text);
  background: var(--cf7-bg);
  border: 1px solid var(--cf7-border);
  border-radius: var(--cf7-radius);
  box-sizing: border-box;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

/* input / select */
.wpcf7 input[type="text"],
.wpcf7 input[type="email"],
.wpcf7 input[type="date"],
.wpcf7 input[type="tel"],
.wpcf7 input[type="url"],
.wpcf7 input[type="number"],
.wpcf7 select {
  min-height: var(--cf7-height);
  padding: 0 14px;
}

/* textarea */
.wpcf7 textarea {
  min-height: 160px;
  padding: 14px;
  resize: vertical;
}

/* selectのみappearance */
.wpcf7 select {
  appearance: none;
  -webkit-appearance: none;

  background-image:
    linear-gradient(45deg, transparent 50%, #666 50%),
    linear-gradient(135deg, #666 50%, transparent 50%);
  background-position:
    calc(100% - 20px) calc(50% - 3px),
    calc(100% - 14px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 40px;
}

/* focus(アクセシビリティ対応) */
.wpcf7 input:focus,
.wpcf7 select:focus,
.wpcf7 textarea:focus {
  outline: none;
  border-color: var(--cf7-border-focus);
  box-shadow: 0 0 0 1px var(--cf7-border-focus);
}

/* placeholder */
.wpcf7 input::placeholder,
.wpcf7 textarea::placeholder {
  color: #999;
}

/* =========================
   checkbox / radio
========================= */
.wpcf7 .wpcf7-checkbox,
.wpcf7 .wpcf7-radio {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.wpcf7 .wpcf7-list-item {
  display: block;
  margin: 0;
}

.wpcf7 .wpcf7-list-item label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.5;
  cursor: pointer;
}

.wpcf7 input[type="checkbox"],
.wpcf7 input[type="radio"] {
  margin: 0;
  transform: translateY(1px);
}

/* =========================
   送信ボタン
========================= */
.wpcf7 input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-width: 180px;
  min-height: 52px;
  padding: 0 24px;

  border: 1px solid var(--cf7-button-bg);
  border-radius: var(--cf7-radius);
  background: var(--cf7-button-bg);
  color: var(--cf7-button-text);

  font-size: 16px;
  font-weight: 700;
  line-height: 1;

  cursor: pointer;
  transition: opacity 0.2s ease, background-color 0.2s ease;

  appearance: none;
  -webkit-appearance: none;
}

.wpcf7 input[type="submit"]:hover {
  opacity: 0.85;
}

.wpcf7 input[type="submit"]:active {
  transform: translateY(1px);
}

.wpcf7 input[type="submit"]:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* 中央寄せ */
.wpcf7 form > p:last-of-type {
  text-align: center;
}

/* スピナー */
.wpcf7 .wpcf7-spinner {
  vertical-align: middle;
  margin-left: 10px;
}

/* =========================
   バリデーション
========================= */
.wpcf7 .wpcf7-not-valid-tip {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--cf7-danger);
}

.wpcf7 .wpcf7-not-valid {
  border-color: var(--cf7-danger) !important;
}

/* =========================
   メッセージ
========================= */
.wpcf7 .wpcf7-response-output {
  margin: 24px 0 0;
  padding: 12px 16px;
  border-radius: var(--cf7-radius);
  font-size: 14px;
  line-height: 1.6;
}

/* 成功 */
.wpcf7 form.sent .wpcf7-response-output {
  color: var(--cf7-success-text);
  background: var(--cf7-success-bg);
  border: 1px solid var(--cf7-success-border);
}

/* エラー */
.wpcf7 form.invalid .wpcf7-response-output,
.wpcf7 form.unaccepted .wpcf7-response-output,
.wpcf7 form.failed .wpcf7-response-output,
.wpcf7 form.aborted .wpcf7-response-output,
.wpcf7 form.spam .wpcf7-response-output {
  color: var(--cf7-danger);
  background: var(--cf7-danger-bg);
  border: 1px solid var(--cf7-danger-border);
}

/* 送信中 */
.wpcf7 form.submitting input[type="submit"] {
  opacity: 0.7;
  pointer-events: none;
}

/* 日付UI */
.wpcf7 input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.75;
}

/* autofill対策 */
.wpcf7 input:-webkit-autofill,
.wpcf7 input:-webkit-autofill:hover,
.wpcf7 input:-webkit-autofill:focus,
.wpcf7 textarea:-webkit-autofill,
.wpcf7 select:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--cf7-bg) inset;
  -webkit-text-fill-color: var(--cf7-text);
}

/* =========================
   スマホ
========================= */
@media (max-width: 767px) {
  .wpcf7 {
    --cf7-space: 20px;
  }

  .wpcf7 form > p {
    margin-bottom: 20px;
  }

  .wpcf7 input[type="submit"] {
    width: 100%;
    min-width: 0;
  }
}

記事一覧へ戻る

関連記事 Relation Entry