<div id="wrap">
<div class="center">
<div class="section">
<div class="input">
<span>+7</span>
<input type="tel">
</div>
</div>
</div>
</div>
// autoprefixer: true
html,
body {
margin: 0;
padding: 0;
font-family: sans-serif;
font-size: 16px;
line-height: 1.4;
color: #555;
background: #fff;
}
* {
box-sizing: border-box;
}
#wrap {
position: relative;
padding-top: 60px;
transition: padding-top .3s ease;
}
.section {
padding: 40px;
}
.center {
width: 100%;
max-width: 1200px;
margin: auto;
}
.input {
position: relative;
width: 180px;
height: 42px;
span {
display: block;
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 30px;
line-height: 42px;
text-align: center;
font-size: 14px;
border-right: 1px solid #eee;
}
}
input {
width: 100%;
height: 100%;
border: 0;
background: #fff;
padding: 0 10px 0 40px;
font-size: 14px;
box-shadow: 0 0 0 1px #aaa;
transition: box-shadow .1s ease;
outline: none;
&:focus {
box-shadow: 0 0 0 2px #777;
}
}
View Compiled
$(function () {
$('input').on('keyup change', function () {
var $input = $(this),
inputVal = $input.val();
if (inputVal[0] == 8 && inputVal.length > 10) {
inputVal = $input.val().substring(1);
}
$input.val(inputVal.replace(/\s+/g, ' ').trim());
});
});
This Pen doesn't use any external CSS resources.