html - wordpress html和css中的响应式图像
问题描述
我试图在 wordpress 上制作响应式图像,但我似乎无法让它工作。
<img class="alignheader wp-image-3295" src="image/wp-content/uploads/2021/07/banner-02-1-300x66.png" alt="" width="1920" height="424" />
<div style="text-align: center;"><a href="#"><img src="image/wp-content/uploads/2021/07/banner-09.png" alt="" width="500" height=""289" /></a>
<a href="#"><img src="image/wp-content/uploads/2021/07/banner-10.png" alt="" width="500" height=""289/" /></a></div>
<div style="text-align: center;"><a href="#"> <img src="image/wp-content/uploads/2021/07/banner-4x.png" alt="bottom" class="alignbottom" />
这是我的CSS
.alignbottom { width: 100vh;
height: 20vh;
border: 3px solid tomato;
object-fit: cover;
object-position: 0 0; }
解决方案
尝试这个:
<html>
<head>
<style>
#img1{
width: 100%;
height: 100%;
border: 3px solid tomato;
object-fit: cover;
object-position: 0 0;
}
.img-div{
width: 400px;
height: 300px
}
</style>
</head>
<div class="img-div">
<img id="img1" src="YOUR_IMAGE_URL" />
</div>
</html>
主要是:object-fit: cover;
推荐阅读
- r - R:将列与作为列表对象存在的另一列中的值进行比较
- python - 添加超范围;如何?
- ios - 反应本机firebase +iOS +异常'不能使用queryEndingAtValue:
- php - 我的 PHP 邮件程序代码给出了 HTTP 500 错误
- javascript - 尝试删除 api 密钥但得到“等待仅在异步函数中有效”
- javascript - 编译 swig 包装的 cxx 文件时 v8.h 中出现未定义的引用错误
- xamarin.ios - 在后台时从 Xamarin iOS 提交数据
- c# - 为什么while循环之后的语句被执行?
- c++ - 如何将派生类的指针传递给基类指针的引用?
- c# - 考虑类的多个属性的优雅排序算法