#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 :: bootstrap Changing the separator |
Css :: css transition slide up |
Css :: css grid minmax function |
Css :: padding shorthand |
Css :: css position sticky |
Css :: css thinner hr |
Css :: comments in css |
Css :: not hover css |
Css :: onclick jquery add css |
Css :: html5 input required length |
Css :: border-radius cross browser |
Css :: show all available virtual environments python |
Css :: remove cursor pointer css |
Css :: css grid auto wrap |
Css :: tailwind center vertically |
Css :: a no underline |
Css :: insert background image css error |
Css :: hard blink |
Css :: rotate element css |
Css :: css animation properties |
Css :: not checked css |
Css :: force aspect ratio div |
Css :: css font family narrow fonts |
Css :: change color when you mouse over a link (hover) |
Css :: css position fixed center |
Css :: textarea disable resize |
Css :: how to hide some grid items from grid in css |
Css :: text shadow effect |
Css :: box model css |
Css :: how to define global font in css |