<div data-attr="readonly" class="card">
<input class="form-control" type="text" placeholder="Readonly input here…" readonly>
</div>
<div data-attr="disabled" class="card">
<input class="form-control" type="text" placeholder="Disabled input here…" disabled>
</div>
<div data-attr="enabled" class="card">
<input class="form-control" type="text" placeholder="Enabled input here…">
</div>
<div data-attr="read-write" class="card">
<input class="form-control" type="text" placeholder="Read write input here…">
</div>
<div data-attr="contenteditable" class="card">
<div contenteditable>Read write div element</div>
</div>
body {
width: 100vw;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: flex-start;
padding: 2vw;
background: #eaeaea;
}
.card {
border-radius: 8px;
padding: 40px;
background: #fff;
border: 1px solid #aeaeae;
margin: 10px;
position: relative;
&::before {
content: attr(data-attr);
position: absolute;
padding: 10px;
background: linear-gradient(to right, #f36, #f63);
color: #fff;
border-radius: 5px;
top: -25px;
}
}
div[contenteditable] {
display: block;
width: 100%;
padding: .375rem .75rem;
font-size: 1rem;
line-height: 1.5;
color: #495057;
background-color: #fff;
background-clip: padding-box;
border: 1px solid #ced4da;
border-radius: .25rem;
transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
}
input:read-only {
border: solid 2px blue;
}
div[contenteditable]:read-write,
input:read-write {
border: solid 2px red;
}
View Compiled
This Pen doesn't use any external JavaScript resources.