css keep image aspect ratio
CSS
.container {
background-color: red;
width: 100%;
padding-top: 100%; /* 1:1 Aspect
Ratio */
position: relative; /* If you want
text inside of it */
}
/* If you
want text inside of the container */
.text {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
.container {
padding-top: 66.66%; /*
3:2 Aspect
Ratio (divide 2 by 3 = 0.6666) */
}
img {
display: block;
max-width: 100%;
max-height: 100%;
width: auto;
height: auto;
}.container {
padding-top: 56.25%; /* 16:9 Aspect
Ratio (divide 9 by 16 = 0.5625) */
}
.container {
padding-top: 62.5%; /*
8:5 Aspect
Ratio (divide 5 by 8 = 0.625) */
}
.container {
padding-top: 75%; /*
4:3 Aspect
Ratio (divide 3 by 4 = 0.75) */
}
Also in CSS:
- Title
- css animations examples
- Category
- CSS
- Title
- how to change height font css
- Category
- CSS
- Title
- html dim entire screen
- Category
- CSS
- Title
- aliceblue hex
- Category
- CSS
- Title
- stop the client from scrolling
- Category
- CSS
- Title
- import google fonts into react
- Category
- CSS
- Title
- select first div css
- Category
- CSS
- Title
- do some css using js on selector
- Category
- CSS
- Title
- ::-ms-clear
- Category
- CSS
- Title
- ios sms css
- Category
- CSS
- Title
- css text shadow not showing in mac chrome
- Category
- CSS
- Title
- set items inline html
- Category
- CSS
- Title
- npm 'cross-env' is not recognized as an internal or external command
- Category
- CSS
- Title
- nth child css
- Category
- CSS
- Title
- corona.html:61 Uncaught ReferenceError: $ is not defined
- Category
- CSS
- Title
- transition prefixes css
- Category
- CSS
- Title
- text underline hover css
- Category
- CSS
- Title
- CKEDITOR PUSH TEXT IN FRONT OF CURSOR
- Category
- CSS
- Title
- css keep background image from scrolling
- Category
- CSS
- Title
- css border
- Category
- CSS
- Title
- dark mode css
- Category
- CSS
- Title
- css make input unselectable
- Category
- CSS
- Title
- wrap DOM elements in SVG using before and after
- Category
- CSS
- Title
- css zen garden
- Category
- CSS
- Title
- because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
- Category
- CSS
- Title
- how to style rule to apply the Border Box model css
- Category
- CSS
- Title
- javascript get css variable
- Category
- CSS
- Title
- remove blue border on a input
- Category
- CSS
- Title
- js ransform css
- Category
- CSS
- Title
- change select arrow css
- Category
- CSS
- Title
- gcd
- Category
- CSS
- Title
- how to hover over an individual cell in table css
- Category
- CSS
- Title
- will change css
- Category
- CSS
- Title
- how to apply different properties to different paragraphs in css
- Category
- CSS
- Title
- Ul or ol with no indent
- Category
- CSS
- Title
- responsive font sizing css
- Category
- CSS
- Title
- position background image
- Category
- CSS
- Title
- how to link fonts css
- Category
- CSS
- Title
- css font style
- Category
- CSS
- Title
- background color css
- Category
- CSS
- Title
- nth-child(2n+1)
- Category
- CSS
- Title
- flexbox css
- Category
- CSS
- Title
- what is a css selector
- Category
- CSS
- Title
- css reset margin padding
- Category
- CSS
- Title
- how to use direct child for ol in css
- Category
- CSS
- Title
- chmod recursive
- Category
- CSS
- Title
- how long ago was 1993 years
- Category
- CSS
- Title
- css nested scrollbars
- Category
- CSS
- Title
- how to make gradient backgroud cover whole page in html
- Category
- CSS
- Title
- asp net css how to change text alignment of gridview column
- Category
- CSS
- Title
- vertical align h1 inside div
- Category
- CSS
- Title
- responsive navbar
- Category
- CSS
- Title
- remove double quotes from string kotlin
- Category
- CSS
- Title
- position an icon in relation a parent element
- Category
- CSS
- Title
- css background video
- Category
- CSS
- Title
- a no line css
- Category
- CSS
- Title
- uibutton image
- Category
- CSS
- Title
- truncate text css
- Category
- CSS
- Title
- difference between :after and ::after
- Category
- CSS
- Title
- make the first item at the very top of the screen
- Category
- CSS
- Title
- add background image css
- Category
- CSS
- Title
- using foundation css to add social media links
- Category
- CSS
- Title
- kerning css
- Category
- CSS
- Title
- css styling
- Category
- CSS
- Title
- adding shadow to a div
- Category
- CSS
- Title
- css inherit class
- Category
- CSS
- Title
- affect top div opacity without affecting childrne
- Category
- CSS
- Title
- how to add background in css
- Category
- CSS
- Title
- breakline css
- Category
- CSS
- Title
- background image in css
- Category
- CSS
- Title
- how to remove link blue color from a tag using css
- Category
- CSS
- Title
- nice button css
- Category
- CSS
- Title
- header html css
- Category
- CSS
- Title
- css anchor fill parent
- Category
- CSS
- Title
- move bullets in css
- Category
- CSS
- Title
- social media icon bar html
- Category
- CSS
- Title
- css ios disable zoom
- Category
- CSS
- Title
- tab link class in html
- Category
- CSS
- Title
- how to add css to html
- Category
- CSS
- Title
- ms-clear event
- Category
- CSS
- Title
- kotlin exit app
- Category
- CSS
- Title
- css in sql query
- Category
- CSS
- Title
- how to add an image in css
- Category
- CSS
- Title
- how to margin placeholdr text
- Category
- CSS
- Title
- css hide element
- Category
- CSS
- Title
- detect if an element has a class jQurey
- Category
- CSS
- Title
- no repeat background
- Category
- CSS
- Title
- not disabled css
- Category
- CSS
- Title
- css transparent background color
- Category
- CSS
- Title
- css note
- Category
- CSS
- Title
- what is responsive design
- Category
- CSS
- Title
- docker exec bash
- Category
- CSS
- Title
- css backdrop filter blut
- Category
- CSS
- Title
- vue import css scoped
- Category
- CSS
- Title
- loading screen svg and css animation
- Category
- CSS
- Title
- css font type
- Category
- CSS
- Title
- css comment tag
- Category
- CSS
- Title
- basic css designn elements
- Category
- CSS
- Title
- css how to style a div
- Category
- CSS
- Title
- move table css
- Category
- CSS