image formatting
Posted in
3496
4:32 am, November 9, 2022
can you set all image heights to match with css no stretching
Short Answer: Yes with object-fit: cover;
on the css of the image properties.
object-fit: cover;
You might also need:
object-position: right bottom;
..
HTML
<h3>Images that are all over the place</h3>
<p>images that do not look nice and formatted in a grid.</p>
<div class="image-heights">
<img src="https://picsum.photos/100/300">
<img src="https://picsum.photos/300/200">
<img src="https://picsum.photos/100/220">
<img src="https://picsum.photos/100/300">
<img src="https://picsum.photos/300/200">
<img src="https://picsum.photos/100/220">
</div>
<hr>
<h3>Add object fit and apply a height and width</h3>
<p>add a class to these images and they all line up nicely with no stretching of the images</p>
<div class="nice-heights">
<img src="https://picsum.photos/100/300">
<img src="https://picsum.photos/300/200">
<img src="https://picsum.photos/100/220">
<img src="https://picsum.photos/100/300">
<img src="https://picsum.photos/300/200">
<img src="https://picsum.photos/100/220">
</div>
CSS
.nice-heights img {
height:200px;
width:200px;
object-fit: cover;
object-position: left top;
margin-bottom:5px;
margin-right:5px;
}
Images that are all over the place
images that do not look nice and formatted in a grid.
Add object fit and apply a height and width
add a class to these images and they all line up nicely with no stretching of the images
View Statistics
This Week
116
This Month
494
This Year
1429
Add Comment
Other Items in image formatting
Related Search Terms
Other Categories in Code
alpine js apps c css factorio font awesome images linux quick modals sqlite site bugs site updates slick slider sliders testing windows apps apache api apps asp bat bootstrap bootstrap templates charts cookies core css css filters css grid design elements docker domains emoji fancybox fonts foundation framework gimp git html icons ideas image formatting images javascript javascript functions jquery js linux mac misc modals mysql nginx node php php errors php function php functions php simple html dom pi400 python react regex sections simple_html_dom simplepie php site bugs site documentation slick slider sql sqlite ssh sublime svg svg css templates tools virtual box vscode vue webdev windows windows 11 windows commands wordpress