Depending on what browsers you’re targeting, you could go for the object-fit property to solve this:
object-fit: cover;
or maybe fill
is what you’re looking for. Still under consideration for IE.
More Related Contents:
- CSS values using HTML5 data attribute [duplicate]
- What is the current state of the “scoped” attribute for the style element in HTML5?
- scale HTML5 Video and break aspect ratio to fill whole site
- How to draw this chart in html and CSS? [closed]
- Change a HTML5 input’s placeholder color with CSS
- Canvas is stretched when using CSS but normal with “width” / “height” properties
- Make a div into a link
- Remove padding from columns in Bootstrap 3
- How can I make an svg scale with its parent container?
- Format text in a ?
- Size of HTML5 Canvas via CSS versus element attributes
- Play/pause HTML 5 video using JQuery
- Center a ‘div’ vertically in a % height ‘div’
- Single huge .css file vs. multiple smaller specific .css files? [closed]
- xHTML/CSS: How to make inner div get 100% width minus another div width
- How to display a reverse-ordered list in HTML?
- CSS div element – how to show horizontal scroll bars only?
- How can I remove space (margin) above HTML header?
- Internet Explorer z-index bug?
- How to customize the HTML5 input range type looks using CSS?
- How to center absolute div horizontally using CSS?
- For div to extend full height
- How to link a CSS file from HTML file?
- SPAN vs DIV (inline-block)
- how to rotate text left 90 degree and cell size is adjusted according to text in html
- Set div height equal to screen size
- Fading out text at bottom of a section with transparent div, but height stays under section after overlaying div
- background-image doesn’t appear if is empty?
- Is there a way to style HTML5’s range control?
- Background image not displaying in chrome browser