Reputation: 1248
I got css file that needed to convert sass. I've handled basics css styles but stuck with this code block. It has a input tag styles.
.search-box input[type='text']{
font-size: 16px;
padding: 3px 5px;
}
.search-box input[type='text']:focus{
outline: 0;
}
.search-box input[type='text']::-webkit-input-placeholder {
color: #000000;
}
.search-box input[type='text']::-moz-placeholder { /* Firefox 19+
color: #000000;
}
.search-box input[type='text']:-ms-input-placeholder {
color: #000000;
}
So I've researched and convert into sass like this.
.search-box {
input[type='text'] {
font-size: 16px;
background-color: #fff;
&:focus {
outline: 0;
}
&::-webkit-input-placeholder {
color: #000000;
}
&::-moz-placeholder {
color: #000000;
}
&:-ms-input-placeholder {
color: #000000;
}
}
}
I need to know that there is a best practice for styling form input tags And did I convert it wrong way here? Please
Upvotes: 1
Views: 3767
Reputation: 2583
Little improvement to your code
@mixin placeholder {
&::-webkit-input-placeholder {@content}
&::-moz-placeholder {@content}
&:-moz-placeholder {@content}
&:-ms-input-placeholder {@content}
}
.search-box {
input[type='text'] {
font-size: 16px;
background-color: #fff;
&:focus {
outline: 0;
}
@include placeholder {
color: #000000;
}
}
}
Upvotes: 4