JSFiddle - React, Tailwind, and code Playground
by mlms13
HTML
<div id="container">
<input id="test" style="margin-left: 40px;" />
<input />
<input />
<input />
</div>
CSS
#container {
margin-left: 40px;
position: relative;
}
input {
display: block;
margin: 6px 0;
}
.warning {
background: #fff;
border: 1px solid #ccc;
border-bottom-color: #aaa;
border-right-color: #aaa;
border-radius: 6px;
box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
font-family: sans-serif;
font-size: 15px;
padding: 8px;
position: absolute;
}
.warning span {
background: #f6a712;
background-image: -webkit-linear-gradient(-45deg, #f6a712, #e98107);
border: 1px solid #ef8c00;
border-top-color: #d18e0f;
border-left-color: #bd7d13;
border-radius: 2px;
color: #fff;
font-family: monospace;
font-size: 14px;
font-weight: bold;
margin-right: 12px;
padding: 0 4px;
text-shadow: 1px 1px 1px rgba(0,0,0,0.6);
}
JavaScript
var a = document.getElementById('test'),
box = document.createElement('div'),
bang = document.createElement('span');
function getDocumentOffset(el) {
var tempLeft = 0, tempTop = 0;
if (el.offsetParent) {
}
}
bang.appendChild(document.createTextNode('!'));
box.className = 'warning';
box.appendChild(bang);
box.appendChild(document.createTextNode('Please fill out this field.'));
box.style.left = a.offsetLeft + 'px';
box.style.top = (a.offsetTop + a.offsetHeight + 2) + 'px';
a.parentNode.insertBefore(box, a.nextSibling);
a.focus();