Positioning Offset Div / Images
I would like to achieve this result (see this example image). First, I’ve tried to create partial borders with CSS (using div:after). Problem : I have several images with diffe
Solution 1:
You don't even need to wrap your <img> elements with <div>: using box-shadow will do the trick:
img {
box-shadow: -10px10px00#fd9220;
margin: 20px;
}<imgalt="example"src="https://via.placeholder.com/150x250"><imgalt="example"src="https://via.placeholder.com/250x150"><imgalt="example"src="https://via.placeholder.com/150x150">The problem with wrapping using a <div> is that it is a block-level element by default, and has a width of 100% unless otherwise specified. This makes it difficult to "shrink wrap" the element around your <img> element, since your image has an undetermined size.
Solution 2:
.container-image-border {
margin-top: 40px;
position: relative;
width: 150px;
height: 250px;
box-shadow: -10px10px00#fd9220;
}<divclass="container-image-border"><imgalt="example"src="https://via.placeholder.com/150x250"></div>Solution 3:
How about box shadows?
img {
background-color: grey;
box-shadow: -30px30px00 orange;
margin-left: 40px; /* just for the presentation */
}<imgalt="example"src="https://placehold.it/150x250">Solution 4:
img {
box-shadow: -10px10px00#fd9220;
margin: 20px;
}<divclass="container-image-border"><imgalt="example"src="https://via.placeholder.com/150x250"></div>
Post a Comment for "Positioning Offset Div / Images"