[CSS] Control Image Aspect Ratio Using CSS
2024-08-24 10:24:11
Resize images and videos to fill their parent and maintain their aspect ratio with pure CSS. The new object-fit
and object-position
properties allow you to scale images and videos, much like you could with background-size
and background-position
.
img {
width: 90vw;
height: 75vh;
border: 3px solid tomato;
} .img-con1 img{
object-fit: fill;
}
.img-con2 img{
object-fit: contain;
}
.img-con3 img{
object-fit: cover;
}
.img-con4 img{
object-fit: none;
} .img-con5 img{
object-fit: scale-down;
} .img-con6 img{
object-fit: fill;
object-position: 20px 5px;
} /* Demo styles only */
* {
box-sizing: border-box;
} body {
margin:;
}
最新文章
- composer的安装以及laravel框架的安装(一)
- Openfire on Centos7
- Window远程连接Linux系统(CentOS7)
- 我和Java有个约定
- Maven+druid+MyBatis+Spring+Oracle+Dubbo开发环境搭建
- Reading package lists... Error! 解决方案
- hdu 3722
- js window.onload事件
- Spring AOP面向切面编程的实现
- SQL Server判断是否满足日期格式(YYYYMMDD)以及中文等判断,格式化为YYYY-MM-DD
- 织云Lite发布:详解包管理核心能力
- Junit-4.1.2 @Test 使用
- NOIP2018Day1T2 货币系统
- [android] 安卓进程优先级&;为什么使用服务
- 细说JDK日志组件
- PHP函数之dirname()
- linux git patch 和patch以及git diff 命令
- CentOS6.5安装sqoop2
- Shell 基础知识和总结
- 12-简单认识下margin