[パーツ]wordpress Contact Form 7を使ったシンプルなメールフォーム

CSS HTML
 2018.07.23

Contact Form 7を使ったシンプルなメールフォーム

wordpressのプラグインであるContact Form 7を使ったシンプルなメールフォームです。

<div class="cp_cf7name">[text* cp_name placeholder "name"]</div>
<div class="cp_cf7email">[email* cp_email placeholder "email"]</div>
<div class="cp_cf7telephone">[tel cp_telephone placeholder "telephone"]</div>
<div class="cp_cf7subject">[select cp_subject first_as_label "Please select" "subject1" "subject2" "subject3"]</div>
<div class="cp_cf7textarea">[textarea cp_textarea placeholder "textarea"]</div>
<div class="cp_cf7submit">[submit "submit"]</div>

*フォームはデモモードになっていますので送信はされませんが、エラーのチェックは可能です。
*サンプルの必須項目は「Name」と「email」です。

browser:  65 11 20 
ニャン易度 
<div class="cp_cont">
<h1>MAIL FORM</h1>
[contact-form-7 id="####" title="####"]
</div>
*, *::before, *::after { -webkit-box-sizing: border-box; box-sizing: border-box; }
.cp_cont {
	width: 90vw;
	max-width: calc(640px - 10px);
	margin: 3em auto 10em auto;
	padding: 16px;
	background: #F2F3EB;
	border: 1px solid #424242;
	box-shadow: #F2F3EB 0px 0px 0px 10px;
}
input[type='text'],
input[type='tel'],
input[type='email'],
textarea,
select {
	vertical-align: top; -webkit-appearance: none; appearance: none;-moz-appearance: none;
	width: 100%; height: 2em;
	padding-left: 0.4em; border: none; border-radius: 0;
	color:#757575;
	background: #F2F3EB;
	font-size: 1em;

}
input[type='text']:focus,
input[type='tel']:focus,
input[type='email']:focus,
textarea:focus,
select:focus {
	outline: none;
}
textarea {
	height: 10em; min-height: 2em;
	resize: none;
}
input[type='text']::placeholder,
input[type='tel']::placeholder,
input[type='email']::placeholder,
textarea::placeholder,
select {
	text-transform: uppercase;
}
input[type='submit'],
input[type='button'],
button {
	cursor: pointer;
	color:#757575;
	background: #F2F3EB;
	border:1px solid #424242;
	padding: 1em 2em;
	transition: all 0.3s;
	text-transform: uppercase;
}
input[type='submit']:hover,
input[type='button']:hover,
button:hover {
	color:#ffffff;
	background: #424242;
}
.cp_cf7name,
.cp_cf7email,
.cp_cf7telephone,
.cp_cf7subject,
.cp_cf7textarea {
	margin: 0 0 2em 0;
}
.cp_cf7name {
	float: left;
	width: 48%;
}
.cp_cf7email {
	float: right;
	width: 48%;
}
.cp_cf7telephone {}
.cp_cf7subject {
	position: relative;
}
.cp_cf7textarea {}
.cp_cf7submit {
	margin: 0 auto;
	text-align: center;
}
.cp_cf7name::after,
.cp_cf7email::after,
.cp_cf7telephone::after,
.cp_cf7subject::after,
.cp_cf7textarea:after {
	display: block;
	width: 100%;
	height: 4px;
	margin-top: -1px;
	content: '';
	border-width: 0 1px 1px 1px;
	border-style: solid;
	border-color: #424242;
}
.cp_cf7subject::before {
	position: absolute;
	top: 0.8em;
	right: 0.2em;
	width: 0;
	height: 0;
	padding: 0;
	content: '';
	border-style: solid;
	border-width: 6px 6px 0 6px;
	border-color: #666666 transparent transparent transparent;
	pointer-events: none;
	z-index: 1;
}
.cp_cont h1 {
	text-align: center;
	margin: 0 auto 2em auto;
	color: #424242;
	position: relative;
	width: 10em;
}
.cp_cont h1::before,
.cp_cont h1::after {
	position: absolute;
	content: '●';
	font-size: 0.3em;
	top: 1.6em;
}
.cp_cont h1::before {
	left: 2em;
}
.cp_cont h1::after {
	right: 2em;
}

copypet.jp

CSS3などで新たに追加された要素・装飾方法など、日々コードを書いていないと忘れてしまったり、ささっとプロトタイプを作る時などちょっとしたことに時間をかけている暇はない。そんな時に「あ〜、あれストックしときゃよかったなぁ」って困った自分用のストックブログです。カスタマイズなどがしやすいよう、昨今のweb制作に取り入れられる一般的なコードを中心に掲載しています。

More Info

こんな記事はいかがですか?