#myDiv
{
height: 104px;
width: 140px;
}
#myDiv img
{
max-width: 100%;
max-height: 100%;
margin: auto;
display: block;
}
/* With img element */
.my-image {
width: 100px;
height: 100px;
object-fit: contain;
}
/* with background image */
.my-image {
width: 500px;
height: 400px;
background-image: url('myurl.jpg');
background-size: cover;
}
.whatever {
width: 500px;
height: 400px;
background-image: url('myurl.jpg');
background-size: cover;
}
Code Example |
---|
Css :: media screen smartphone |
Css :: button highlight none css |
Css :: arrow up css |
Css :: border bottom under text only |
Css :: css smooth scroll |
Css :: sass vs scss |
Css :: line middle text css |
Css :: add image under header html |
Css :: scrollbar css |
Css :: wordpress style.css |
Css :: how to put link at bottom of page html |
Css :: mac input shadow |
Css :: tailwind css image grid |
Css :: hide featured image in wordpress |
Css :: aspect ratio css |
Css :: css all uppercase to capitalize |
Css :: multiple box shadows css |
Css :: *+* css |
Css :: how to select child when hover on parent element css |
Css :: rounded left border tailwind css |
Css :: font weight |
Css :: css math functions |
Css :: css example |
Css :: set min div height |
Css :: <link |
Css :: scss select all childs |
Css :: line height tailwind |
Css :: move text in a padding css |
Css :: css round image without stretching |
Css :: variables scss |