JSFiddle - React, Tailwind, and code Playground
HTML
<body>
<div id="original"></div>
<div id="copycat">
I should line up vertically with the div to my left.
</div>
</body>
CSS
body {
border-top:20px solid red;
font-family: Verdana, Helvetica, sans;
}
#original, #copycat {
position: absolute;
width: 100px;
height: 100px;
}
#original {
top: 100px;
left: 40px;
background-color: blue;
}
#copycat {
left: 150px;
background-color: green;
color: white;
text-align: center;
}
JavaScript
$(function(){
// try to set copycat to the same height as original
$('#copycat').css({
top : $('#original').offset().top + 'px'
});
// but .offset() doesn't seem to take into account
// the border set on the body!
});