[パーツ]メールフォーム フラットなメールフォーム

CSS HTML
 2018.02.07
 2018.03.23

フラットなメールフォーム

フラットなメールフォームです。

browser:  65 11 20 10 
ニャン易度 
<div class="cp_form">
<form class="cp_group">
	<div class="title">
		<h2>Contact Form Sample</h2></div>
	<div class="cp_tx">
		<label class="title">Textfield:</label>
		<input class="large" type="text" name="input" />
	</div>
	<div class="cp_textarea">
		<label class="title">Textarea:</label>
		<textarea class="small" name="textarea" cols="20" rows="5" ></textarea>
	</div>
	<div class="cp_select">
		<label class="title">Select:</label>
		<span>
			<select name="select" >
			<option value="" hidden disabled selected></option>
			<option value="1">cat</option>
			<option value="2">dog</option>
			<option value="3">rabbit</option>
			<option value="4">squirrel</option>
			</select>
			<i></i>
		</span>
	</div>
	<div class="cp_ipradio">
		<label class="title">radiobutton:</label>
		<div class="column column2">
			<label>
				<input type="radio" name="radio" value="radiobutton1" />
				<span>radiobutton1</span>
			</label>
		</div>
		<span class="clearfix"></span>
		<div class="column column2">
			<label>
				<input type="radio" name="radio" value="radiobutton2" />
				<span>radiobutton2</span>
			</label>
		</div>
		<span class="clearfix"></span>
	</div>
	<div class="cp_ipcheck">
		<label class="title">checkbox:</label>
		<div class="column column2">
			<label>
				<input type="checkbox" name="checkbox1" value="checkbox1" />
				<span>checkbox1</span>
			</label>
		</div>
		<span class="clearfix"></span>
		<div class="column column2">
			<label>
				<input type="checkbox" name="checkbox2" value="checkbox2" />
				<span>checkbox2</span>
			</label>
		</div>
		<span class="clearfix"></span>
	</div>
	<div class="cp_file">
		<label class="title">File:</label>
		<label class="large">
			<div class="button">Choose File</div>
			<input type="file" class="file_input" name="file" />
			<div class="file_text">No file selected</div>
		</label>
	</div>
	<div class="submit">
		<input type="submit" value="Send" />
	</div>
</form>
</div>
.cp_form .cp_group {
position: relative;
width: 600px;
margin: 40px auto;
box-shadow:0px 0px 3px 2px #ededed;
}
.cp_form .cp_group > div, .cp_group > .title {
margin: 8px;
}
.cp_form .cp_group .column {float: left;}
.cp_form .cp_group .column1 {width: 100%;}
.cp_form .cp_group .column2 {width: 50%;}
.cp_form .cp_group .column3 {width: 33%;}
.cp_form .cp_group .column4 {width: 25%;}
.cp_form .cp_group .column5 {width: 20%;}
.cp_form .cp_group .large {width: 100%;}
.cp_form .cp_group .medium {width: 50%;}
.cp_form .cp_group .small {width: 25%;}
.cp_form .cp_group textarea.large {
width: 100%;
height: 20em;
}
.cp_form .cp_group textarea.medium {
width: 100%;
height: 10em;
}
.cp_form .cp_group textarea.small {
width: 100%;
height: 5.5em;
}
.cp_form .clearfix {
*zoom: 1;
}
.cp_form .clearfix:before, .cp_form .clearfix:after {
display: table;
line-height: 0;
content: '';
}
.cp_form .cp_group {
font-size: 1em;
line-height: 1.231;
border: 2px solid #7f8c8d;
border-radius: 6px;
}
.cp_form .cp_group label.title {
font-size: 1em;
font-weight: 500;
width: auto;
}
.cp_form .cp_group input[type=button] {
font-size: 1em;
color: #666666;
outline: none;
}
.cp_form .cp_group input[type=submit] {
font-size: 1.2em;
color: #666666;
outline: none;
}
.cp_form .cp_group > div {
position: relative;
margin-right: 25px;
margin-left: 25px;
}
.cp_form .cp_group h2 {
font-size: 1.7em;
margin: 0.2em 0;
color: #ffffff;
}
.cp_form .cp_group h3.title {
margin-top: 1.5em;
margin-bottom: 0.5em;
}
.cp_form .cp_group label {
display: block;
clear: both;
margin-bottom: 3px;
}
.cp_form .cp_group div, .cp_form .cp_group span,
.cp_form .cp_group label, .cp_form .cp_group input,
.cp_form .cp_group textarea, .cp_form .cp_group select,
.cp_form .cp_group button, .cp_form .cp_group ul,
.cp_form .cp_group li, .cp_form .cp_group a {
font-family: inherit;
color: inherit;
}
/* submit + title */
.cp_form .cp_group div.submit,
.cp_form .cp_group div.title {
margin: 0;
padding-top: 1em;
padding-bottom: 1em;
}
.cp_form .cp_group div.submit {
text-align: right;
vertical-align: middle;
border-top: 2px solid #bdc3c7;
border-radius: 0 0 6px 6px;
}
.cp_form .cp_group div.title {
background-color: #7f8c8d;
}
.cp_form .cp_group div.title h2 {
margin-left: 27px;
}
/* element-submit + element-text */
.cp_form .cp_group > .submit,
.cp_form .cp_group > .title {
background-color: #bcc3ca;
}
.cp_form .cp_group > .submit {
background-color: #ecf0f1;
}
/* Button & submit*/
.cp_form .cp_group input[type=button],
.cp_form .cp_group input[type=submit] {
display: inline-block;
margin-bottom: 1px;
padding: 4px 12px;
cursor: pointer;
-webkit-transition: border-color 0.6s;
transition: border-color 0.6s;
text-align: left;
vertical-align: middle;
color: #666666;
border: 2px solid #bdc3c7;
border-radius: 6px;
background: #ffffff;
-webkit-appearance: none;
appearance: normal;
}
.cp_form .cp_group input[type=button][disabled] {
cursor: default;
opacity: 0.65;
}
.cp_form .cp_group input[type=submit] {
right: 20px;
margin-right: 27px;
padding: 7px 15px;
-webkit-transition: background-color 0.25s;
transition: background-color 0.25s;
text-align: center;
opacity: 1;
color: #ffffff;
border: none;
}
.cp_form .cp_group input[type=submit]:hover {
text-decoration: none;
}
/* File input */
.cp_form .cp_group .cp_file label {
position: relative;
}
.cp_form .cp_group .cp_file .title {
position: static;
}
.cp_form .cp_group .cp_file .button {
font-size: 1em;
position: absolute;
z-index: 1;
top: 0;
right: 0;
bottom: 0;
float: none;
padding: 1.8% 1.2em 0 1.2em;
cursor: pointer;
-webkit-transition: background-color 0.25s;
transition: background-color 0.25s;
color: #ffffff;
border-radius: 0 6px 6px 0;
}
.cp_form .cp_group .cp_file .file_text {
overflow: hidden;
-webkit-transition: border-color 0.25s;
transition: border-color 0.25s;
}
.cp_form .cp_group .cp_file .file_input {
position: absolute;
top: 0;
right: 0;
bottom: 0;
width: 100%;
padding: 0;
cursor: pointer;
opacity: 0;
filter: alpha(opacity=0);
}
/* Radio & checkbox */
.cp_form .cp_group div.cp_ipcheck,
.cp_form .cp_group div.cp_ipradio {
overflow: hidden;
}
.cp_form .cp_group input[type=checkbox],
.cp_form .cp_group input[type=radio] {
font-size: 1em;
position: absolute;
z-index: 1;
float: left;
width: 1em;
height: 1em;
margin: 0;
cursor: pointer;
opacity: 0.01;
}
.cp_form .cp_group input[type=radio] + span,
.cp_form .cp_group input[type=checkbox] + span {
height: 19px;
margin-right: -19px;
padding-top: 0;
z-index: 0;
position: relative;
left: 0;
top: 0;
vertical-align: top;
font-size: 1em;
line-height: 0.8;
cursor: pointer;
}
.cp_form .cp_group input[type=radio] + span:before,
.cp_form .cp_group input[type=checkbox] + span:before {
font-family: 'FontAwesome';
font-size: 1em;
line-height: 1;
position: relative;
display: inline-block;
width: 1em;
margin: 0 0.2em;
vertical-align: top;
}
/* checkbox */
.cp_form .cp_group input[type=checkbox] + span:before {
content: '\f096';
-webkit-transition: color 0.5s;
transition: color 0.5s;
}
.cp_form .cp_group input[type=checkbox]:hover + span:before {
content: '\f046';
}
.cp_form .cp_group input[type=checkbox]:checked + span:before {
content: '\f046';
}
/* radio */
.cp_form .cp_group input[type=radio] + span:before {
content: '\f096';
-webkit-transition: color 0.5s;
transition: color 0.5s;
}
.cp_form .cp_group input[type=radio]:hover + span:before {
content: '\f0c8';
}
.cp_form .cp_group input[type=radio]:checked + span:before {
content: '\f0c8';
}
.cp_form .cp_group input[type=text],
.cp_form .cp_group input[type=tel],
.cp_form .cp_group input[type=password],
.cp_form .cp_group input[type=email],
.cp_form .cp_group input[type=url],
.cp_form .cp_group input[type=date],
.cp_form .cp_group input[type=number],
.cp_form .cp_group textarea,
.cp_form .cp_group .cp_file .file_text,
.cp_form .cp_group select {
font-size: 1em;
box-sizing: border-box;
padding: 6px 10px;
-webkit-transition: border-color 0.6s;
transition: border-color 0.6s;
border-width: 2px;
border-style: solid;
border-color: #bdc3c7;
border-radius: 6px;
outline: none;
-webkit-appearance: none;
appearance: normal;
}
.cp_form .cp_group select::-ms-expand {
display: none;
}
.cp_form .cp_group input[type=text],
.cp_form .cp_group .cp_file .file_text,
.cp_form .cp_group textarea {
width: 100%;
}
.cp_form .cp_group textarea {
height: auto;
}
.cp_form .cp_group select {
width: 100%;
cursor: pointer;
text-align: left;
}
/* type number */
.cp_form .cp_group input[type=number]::-webkit-inner-spin-button,
.cp_form .cp_group input[type=number]::-webkit-outer-spin-button {
-webkit-appearance: none;
}
@media all and (max-width:400px) {
.cp_form .cp_group .cp_ipradio .column,
.cp_form .cp_group .cp_ipcheck .column {
display: block;
width: 100%;
margin-right: 0;
}
}
/* .cp_group color scheme begin */
.cp_form .cp_group input[type=button]:focus,
.cp_form .cp_group input[type=button]:active,
.cp_form .cp_group input[type=button][disabled] {
border-color: #da3c3c;
}
.cp_form .cp_group input[type=submit] {
background-color: #da3c3c;
}
.cp_form .cp_group input[type=submit]:hover {
background-color: #ff4b4b;
}
.cp_form .cp_group input[type=submit]:active {
background-color: #b02f2f;
}
/* File input */
.cp_form .cp_group .cp_file .button {
background-color: #bdc3c7;
}
.cp_form .cp_group .cp_file .file_text {
border-color: #bdc3c7;
}
.cp_form .cp_group .cp_file label:hover .button {
background-color: #da3c3c;
}
.cp_form .cp_group .cp_file label:active .button {
background-color: #b02f2f;
}
.cp_form .cp_group .cp_file label:hover .file_text {
border-color: #da3c3c;
}
.cp_form .cp_group .cp_file label:active .file_text {
border-color: #b02f2f;
}
/* Radio & checkbox */
.cp_form .cp_group input[type=radio]+span:before,
.cp_form .cp_group input[type=checkbox] + span:before {
color: #bdc3c7;
}
/* checkbox */
.cp_form .cp_group input[type=checkbox]:checked + span:before {
color: #da3c3c;
}
/* radio */
.cp_form .cp_group input[type=radio]:checked + span:before {
color: #da3c3c;
}
.cp_form .cp_group input[type=text]:focus,
.cp_form .cp_group input[type=tel]:focus,
.cp_form .cp_group input[type=password]:focus,
.cp_form .cp_group input[type=email]:focus,
.cp_form .cp_group input[type=url]:focus,
.cp_form .cp_group input[type=date]:focus,
.cp_form .cp_group input[type=number]:focus,
.cp_form .cp_group textarea:focus,
.cp_form .cp_group .cp_file .file_text:active,
.cp_form .cp_group  select:focus {
border-color: #da3c3c;
}
/*select*/
.cp_form .cp_group .cp_select span {
position: relative;
}
.cp_form .cp_group .cp_select i::before {
position: absolute;
top: 0.4em;
right: 0.9em;
width: 0;
height: 0;
padding: 0;
content: '';
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-top: 6px solid #666666;
pointer-events: none;
}
.cp_form .cp_group select:focus + i::before {
border-top: 6px solid #da3c3c;
}

copypet.jp

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

More Info

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