I believe that to achieve this, you will need three div's
(maybe someone can come up with two div
solutions). Here is an example script . Three nested div
elements (the outer one has the .CropIt
class):
CSS
.CropIt { overflow: hidden; width: 60px; } .CropIt > div { border: 20px solid red; width: 20px; } .CropIt > div > div { margin: -20px; }
The outer sets an overflow to hide the hidden border. The middle sets the width and the border (the outer should match this total width or use a float
to compress the wrapper). The innermost sets a negative margin for moving content along the middle border and creates a border overlap to the middle of the div
.
source share