FormをCSSでカスタマイズ
JMUGのみなさま、こんにちは大里です。
以前に石野さんがFormをCSSでカスタマイズする方法を動画で紹介してくれてますが、その投稿の続編的な内容です。
▼石野さんの投稿
まず前提として私はCSSに関しては素人というか、ちょこっと扱える程度です。
Google先生に尋ねながら、なんとなく書けるレベル。
なので下記で紹介するコードはツッコミ所が満載だと思いますし
考慮仕切れてない要素や条件が多々あるのは承知していますが
それでもMarketoユーザーのみなさまにとって、役立てると思いますのでシェアします。
可能であればJMUGのみなさまで、このへっぽこCSSをブラッシュアップしたり「こんなの作ってたよー」
といったやりとりができれば嬉しいです。
ということで、CSSです。
/* Add your custom CSS below */
#mktoStyleLoaded {
background-color: #123456;
display: none
}
.mktoForm {
text-align: left!important;
width: 750px!important;
margin: 0 auto!important;
color: #4d4d4d!important
}
.mktoForm .mktoClear {
clear: both;
float: none
}
.mktoForm div,.mktoForm label,.mktoForm p,.mktoForm span {
text-align: left!important;
margin: 0;
padding: 0
}
.mktoForm input,.mktoForm select,.mktoForm textarea {
margin: 0
}
.mktoForm * {
font-family: inherit
}
.mktoForm .mktoGutter,.mktoForm .mktoOffset {
float: left;
height: 1.2em
}
.mktoForm .mktoFieldWrap {
float: left;
width: 750px!important
}
.mktoForm .mktoHtmlText {
width: 500px!important;
margin-left: 200px!important
}
.mktoForm .mktoLabel {
min-width: 200px!important;
min-height: 40px!important;
float: left;
padding-top: 0!important;
font-weight: 400!important;
text-align: left!important
}
.mktoForm .mktoField {
line-height: 1.2em;
font-size: 1em;
float: left
}
.mktoForm .mktoLogicalField,.mktoForm .mktoPlaceholder {
float: left
}
.mktoForm fieldset {
padding: 0;
margin: 0
}
.mktoForm fieldset legend {
margin: 0 1em .5em;
color: inherit
}
.mktoForm a.mktoNotYou {
cursor: pointer;
color: #4692f3
}
.mktoForm a.mktoNotYou:hover {
text-decoration: underline
}
.mktoForm .mktoAsterix {
float: right;
color: #c0a16c;
padding-left: 5px;
display: none
}
.mktoForm .mktoCheckboxList,.mktoForm .mktoRadioList {
float: left;
padding: 1.2rem!important
}
.mktoForm .mktoCheckboxList>label,.mktoForm .mktoRadioList>label {
margin-left: 1.5em;
margin-top: .1em;
margin-bottom: .3em;
line-height: 1.2em;
display: block;
min-height: 12px
}
.mktoForm.ie7 .mktoCheckboxList>label,.mktoForm.ie7 .mktoRadioList>label {
padding: .2em 0 0
}
.mktoForm .mktoCheckboxList>label>input,.mktoForm .mktoRadioList>label>input {
float: left;
margin: 0
}
.mktoForm input[type=checkbox] {
-webkit-appearance: checkbox;
width: 20px;
height: 20px;
border: 1px solid #dedede;
border-radius: 2px
}
.mktoForm input[type=checkbox]:checked {
content: "\2713"
}
.mktoForm .mktoLabelToLeft>label {
text-align: right;
margin-left: 0;
margin-right: 1.5em
}
.mktoForm .mktoLabelToLeft input[type=checkbox],.mktoForm .mktoLabelToLeft input[type=radio] {
position: absolute;
right: .3em
}
.mktoForm.mktoLayoutAbove .mktoRequiredField .mktoAsterix {
float: left;
padding-left: 0;
padding-right: 5px
}
.mktoForm .mktoRequiredField .mktoAsterix {
display: block
}
.mktoForm .mktoRequiredField label.mktoLabel {
font-weight: 700
}
.mktoForm input[type=date],.mktoForm input[type=email],.mktoForm input[type=number],.mktoForm input[type=tel],.mktoForm input[type=text],.mktoForm input[type=url]{
width: 500px!important;
height: 40px!important;
padding: 2px 0 2px 10px!important;
background-position: 5px 5px;
border: 1px solid #eae7e6;
background-color: #fff;
border-radius: 0;
box-shadow: none
}
.mktoForm input[type=range] {
padding: .25em 0;
margin: 0
}
.mktoForm input[type=range]::-ms-tooltip {
display: none
}
.mktoForm input[type=date],.mktoForm input[type=email],.mktoForm input[type=number],.mktoForm input[type=tel],.mktoForm input[type=text],.mktoForm input[type=url]{
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box
}
.mktoForm ::placeholder {
color: #ddd8d5!important
}
.mktoForm select.mktoField {
width: 500px!important;
height: 40px!important;;
padding: 2px 0 2px 10px!important;
background-position: 5px 5px;
border: 1px solid #eae7e6;
background-color: #fff;
border-radius: 0!important;;
box-shadow: none!important;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box
}
.mktoForm textarea.mktoField {
width: 500px!important;
height: 150px!important;;
padding: 2px 0 2px 10px!important;
background-position: 5px 5px;
border: 1px solid #eae7e6;
background-color: #fff;
border-radius: 0;
box-shadow: none!important;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box
}
.mktoForm .mktoFormRow {
clear: both
}
.mktoForm .mktoFormCol {
float: left;
position: relative;
min-height: 2em
}
.mktoButtonRow {
position: relative;
margin: 0 auto!important;
text-align: center;
display: block
}
.mktoInvalid {
border: 1px solid #d5be91!important
}
.mktoForm textarea.mktoField {
display: inline-block;
padding: .2em;
margin: 0;
line-height: 1.2em;
overflow: auto;
resize: none;
float: none
}
.mktoForm textarea[rows="1"] {
height: 2em
}
.mktoForm textarea[rows="2"] {
height: 3.4em
}
.mktoForm textarea[rows="3"] {
height: 4.6em
}
.mktoForm textarea[rows="4"] {
height: 5.8em
}
.mktoForm textarea[rows="5"] {
height: 7em
}
.mktoForm textarea[rows="6"] {
height: 8.2em
}
.mktoForm textarea[rows="7"] {
height: 9.4em
}
.mktoForm textarea[rows="8"] {
height: 10.6em
}
.mktoForm.mktoLayoutCenter .mktoLabel {
text-align: right
}
.mktoForm.mktoLayoutAbove .mktoGutter {
display: none
}
.mktoForm.mktoLayoutAbove .mktoLabel {
text-align: left
}
.mktoForm.mktoLayoutAbove .mktoCheckboxList,.mktoForm.mktoLayoutAbove .mktoRadioList {
float: none;
clear: left
}
.mktoForm.mktoLayoutAbove .mktoField,.mktoForm.mktoLayoutAbove .mktoLogicalField {
clear: left
}
.mktoForm.mktoLayoutAbove textarea.mktoField {
float: left
}
.mktoForm .mktoError {
position: absolute;
z-index: 99;
color: #bf0000
}
.mktoForm .mktoError .mktoErrorArrowWrap {
width: 16px;
height: 8px;
overflow: hidden;
position: absolute;
top: 0;
left: 5px;
z-index: 100
}
.mktoForm.ie7 .mktoError .mktoErrorArrowWrap {
top: -8px
}
.mktoForm .mktoError .mktoErrorArrow {
background-color: #e51b00;
border: 1px solid #9f1300;
border-right: none;
border-bottom: none;
display: inline-block;
height: 16px;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
transform: rotate(45deg);
-ms-transform: rotate(45deg);
width: 16px;
margin-top: 5px
}
.mktoForm .mktoError .mktoErrorArrowWrap.mktoArrowImage {
bottom: -7px
}
.mktoForm .mktoError .mktoErrorArrowWrap.mktoArrowImage .mktoErrorArrow {
display: none
}
.mktoForm .mktoError .mktoErrorMsg {
display: block;
margin-top: 7px;
background-color: #e51b00;
background-image: -webkit-linear-gradient(#e51b00 43%,#ba1600);
background-image: -moz-linear-gradient(#e51b00 43%,#ba1600 100%);
background-image: linear-gradient(#e51b00 43%,#ba1600);
background-image: -ms-linear-gradient(#e51b00 43%,#ba1600 100%);
border: 1px solid #9f1300;
-webkit-border-radius: 6px;
border-radius: 6px;
-webkit-box-shadow: none!important;
box-shadow: none!important;
color: #f3f3f3;
font-size: 1em;
line-height: 1.2em;
max-width: 16em;
padding: .4em .6em;
text-shadow: #901100 0 -1px 0
}
.mktoForm .mktoError .mktoErrorMsg .mktoErrorDetail {
display: block
}
.mktoForm button.mktoButton {
cursor: pointer;
margin: 0 auto!important;
display: block!important;
background: #ee4025!important;
border: none!important;
border-radius: 3px!important;
-webkit-box-shadow: none!important;
box-shadow: none!important;
color: #fff!important;
font-size: 14px!important;
padding: 8px 0 9px!important;
text-align: center!important;
text-shadow: none!important;
width: 180px!important;
height: 50px!important;
font-family: Noto Sans Japanese,Hiragino Kaku Gothic ProN,MyYuGothicM,YuGothic,メイリオ,Meiryo,sans-serif
}
.mktoForm button.mktoButton:disabled {
opacity: .5;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
filter: alpha(opacity=50);
cursor: default
}
.mktoNoJS .mktoLabel {
display: block;
padding-right: 10px;
width: 110px;
text-align: right
}
.mktoNoJS input[type=text] {
width: 150px
}
.mktoForm .cf_widget_socialsignon .cf_sign_on {
margin-bottom: 1.5em
}
.mktoForm .mktoRangeField .mktoRangeValue {
zoom:1;float: left;
display: none;
text-align: center;
position: absolute;
z-index: 99;
color: #000
}
.mktoForm.ie6 .mktoRangeField .mktoRangeValue,.mktoForm.ie7 .mktoRangeField .mktoRangeValue {
position: relative
}
.mktoForm .mktoRangeField.mktoHover .mktoRangeValue {
display: block
}
.mktoForm .mktoRangeField .mktoRangeValueArrowWrap {
width: 16px;
height: 8px;
overflow: hidden;
position: absolute;
bottom: -7px;
z-index: 100
}
.mktoForm .mktoRangeField .mktoRangeValueArrow {
background-color: #028d05;
border: 1px solid #005602;
height: 16px;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
transform: rotate(45deg);
-ms-transform: rotate(45deg);
width: 16px;
background-color: #007d04;
border-left: none;
border-top: none;
margin-top: 5px;
position: absolute;
bottom: 5px
}
.mktoForm .mktoRangeField .mktoRangeValueArrowWrap.mktoArrowImage {
bottom: -7px
}
.mktoForm .mktoRangeField .mktoRangeValueArrowWrap.mktoArrowImage .mktoRangeValueArrow {
display: none
}
.mktoForm .mktoRangeField .mktoRangeValueText {
display: block;
background-color: #028d05;
background-image: -webkit-linear-gradient(#028d05 43%,#007d04);
background-image: -moz-linear-gradient(#028d05 43%,#007d04 100%);
background-image: linear-gradient(#028d05 43%,#007d04);
background-image: -ms-linear-gradient(#028d05 43%,#007d04 100%);
border: 1px solid #005602;
-webkit-border-radius: 6px;
border-radius: 6px;
-webkit-box-shadow: rgba(0,0,0,.65) 0 2px 7px,inset #00a500 0 1px 0;
box-shadow: 0 2px 7px rgba(0,0,0,.65),inset 0 1px 0 #00a500;
color: #f3f3f3;
font-size: 1em;
line-height: 1.2em;
padding: .4em .6em;
text-shadow: #005602 0 -1px 0;
text-align: center
}
.mktoModal,.mktoModal .mktoModalMask {
position: absolute;
top: 0;
left: 0;
right: 0
}
.mktoModal .mktoModalMask {
z-index: 10000;
zoom:1;background: rgba(0,0,0,.5);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#80000000,endColorstr=#80000000);
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#80000000, endColorstr=#80000000)"
}
.mktoModal .mktoModalContent {
position: absolute;
z-index: 10001;
background: #fff;
padding: 10px
}
.mktoModal .mktoModalClose {
position: absolute;
cursor: pointer;
top: -10px;
right: -10px;
background: #000;
color: #fff;
width: 19px;
height: 19px;
font-family: Arial,Helvetica,sans-serif;
font-size: 13px;
line-height: 19px;
-webkit-border-radius: 19px;
border-radius: 19px;
text-align: center;
border: 2px solid #ccc
}
@media only screen and (max-width: 480px) {
.mktoForm,.mktoForm * {
-webkit-box-sizing:border-box;
box-sizing: border-box;
-moz-box-sizing: border-box;
padding: 10px
}
.mktoForm .mktoGutter,.mktoForm .mktoOffset {
display: none
}
.mktoForm .mktoFormCol {
float: none
}
.mktoForm .mktoFormCol .mktoLabel {
text-align: left;
width: 100%
}
.mktoForm .mktoFieldWrap {
float: none
}
.mktoForm fieldset {
padding: 0 10px
}
.mktoForm input[type=date],.mktoForm input[type=email],.mktoForm input[type=number],.mktoForm input[type=tel],.mktoForm input[type=text],.mktoForm input[type=url] {
width: 100%!important;
height: 1.5em;
line-height: 1.5em;
font-size: 18px
}
.mktoForm textarea.mktoField {
width: 100%;
height: 1.5em;
line-height: 1.5em;
font-size: 18px;
-webkit-box-shadow: none!important;
box-shadow: none!important
}
.mktoForm select.mktoField {
width: 100%!important;;
height: 1.5em;
border-radius: 0!important;;
line-height: 1.5em;
font-size: 18px;
height: auto
}
.mktoForm .mktoFormRow .mktoField {
clear: left
}
.mktoForm .mktoFormRow .mktoFormCol {
clear: both
}
.mktoForm .mktoCheckboxList,.mktoForm .mktoRadioList {
width: 100%
}
.mktoForm .mktoFormRow .mktoRequiredField .mktoAsterix {
float: left;
padding-left: 0;
padding-right: 5px
}
.mktoModal .mktoModalContent {
padding: 10px 0
}
.mktoModal .mktoModalClose {
right: 0
}
.mktoForm .cf_widget_socialsignon {
display: block
}
.mktoForm .cf_widget_socialsignon .cf_sign_on {
width: 100%
}
.mktoForm .cf_widget_socialsignon .cf_sign_on_button {
width: auto
}
}
@media only screen and (max-device-height: 480px),only screen and (max-device-width:480px),only screen and (max-width:480px) {
.mktoForm *,.mktoMobileShow .mktoForm {
-webkit-box-sizing:border-box;
box-sizing: border-box;
-moz-box-sizing: border-box;
padding: 10px
}
.mktoForm {
width: 100%!important
}
.mktoForm .mktoGutter,.mktoForm .mktoOffset {
display: none
}
.mktoForm .mktoFormCol {
float: none
}
.mktoForm .mktoFormCol .mktoLabel {
text-align: left;
width: 100%!important
}
.mktoForm .mktoFieldWrap {
float: none;
width: 100%!important
}
.mktoForm fieldset {
padding: 0 10px
}
.mktoForm input[type=date],.mktoForm input[type=email],.mktoForm input[type=number],.mktoForm input[type=tel],.mktoForm input[type=text],.mktoForm input[type=url] {
width: 100%;
height: 1.5em;
line-height: 1.5em;
font-size: 18px
}
.mktoForm textarea.mktoField {
width: 100%!important;
height: 100px!important;
line-height: 1.5em;
font-size: 18px
}
.mktoForm select.mktoField {
width: 100%!important;;
height: 1.5em;
line-height: 1.5em;
font-size: 18px;
height: auto
}
.mktoForm .mktoHtmlText {
width: 100%!important;
margin: 0!important
}
.mktoForm .mktoFormRow .mktoField {
clear: left
}
.mktoForm .mktoFormRow .mktoFormCol {
clear: both
}
.mktoForm .mktoCheckboxList,.mktoForm .mktoRadioList {
width: 100%
}
.mktoForm .mktoFormRow .mktoRequiredField .mktoAsterix {
float: left;
padding-left: 0;
padding-right: 5px
}
.mktoModal .mktoModalContent {
padding: 10px 0
}
.mktoModal .mktoModalClose {
right: 0
}
.mktoForm .cf_widget_socialsignon {
display: block
}
.mktoForm .cf_widget_socialsignon .cf_sign_on {
width: 100%
}
.mktoForm .cf_widget_socialsignon .cf_sign_on_button {
width: auto
}
}
めっちゃ長い・・・
ですが、レスポンシブに対応してます。
【PCサイズ】

【スマホサイズ】

※CSSのコードの記述方法についてはサポート対象外となりますので、自己責任でご利用ください。