Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSS

crop image in div

.myImage {
	height: 200px; /* need to define height and width explicitly (to my understanding) */
	width: 200px;

	background-size: cover; /* cover or contain */
	background-image: url('../../images/anderson-schmig-IayJpfDhj7E-unsplash.jpg'); /* load image */
	background-repeat: no-repeat; /* dont tile */
	background-position: center; /* center image | top, bottom, left, right, custom are also valid options */

	border: 1px solid black; /* see edges of container for seeing if we got any errors */
}	

<div class="myImage"></div>
 
PREVIOUS NEXT
Tagged: #crop #image #div
ADD COMMENT
Topic
Name
2+9 =