There are many ways, so in fact it depends more on the “why” than on the “how”, but if the client told me this, my first blow would look something like this:
<div id="div5"> <div id="div1">1</div> <div id="div2">2</div> <div id="div3">3</div> <div id="div4">4</div> Content </div>
with css like:
#div5 { position: relative; margin: 3em; background-color: red; width: 10em; height: 10em; } #div1,#div2,#div3,#div4 { position: absolute; background-color: black; color: white; } #div1, #div3 { width: 100%; height: 2em; } #div1 { top: -2em; } #div3 { bottom: -2em; } #div2, #div4 { height: 100%; width: 2em; } #div2 { right: -2em; } #div4 { left: -2em; }
Spell here
source share