html - 超出指定大小的扩展元素
问题描述
我有这个 html 和这个 css。
.entry-content > .greyfruitdrawing {
height:2000px !important;
width:2000px !important;
margin-top:40px;
}
.redletters1 {
font-size:40px;
opacity:0.7;
color:red;
position:relative;
top: 20px;
font-weight: bolder;
line-height:1.6;
text-align:justify;
}
<div class="greyfruitdrawing">
<img src="http://4309.co.uk/wp-content/uploads/2019/12/IMG_20191205_220426-300x201.jpg" alt=""width="300" height="201"class="alignnone size-medium wp-image-6978"/>
</div>
<div class="redletters1">SOME TEXT.</div>
问题是a)它不会按照css告诉它的大小扩展。b) 元素以它们不应该的方式交互。调整greyfruitdrawing
影响位置redletters1
解决方案
设置外部容器的高度和宽度,然后给图像本身设置 100% 的高度和宽度:
.container {
text-align: center;
width: 2000px;
height: 2000px;
margin-top: 40px;
}
.greyfruitdrawing img {
height: 100%;
width: 100%;
}
.redletters1 {
font-size: 40px;
color: rgba(255,0,0,0.7);
font-weight: bolder;
line-height: 1.6;
}
<div class="container">
<div class="greyfruitdrawing">
<img src="http://4309.co.uk/wp-content/uploads/2019/12/IMG_20191205_220426-300x201.jpg" />
</div>
<div class="redletters1">SOME TEXT.</div>
</div>
推荐阅读
- robotframework - 将 JSON 文件加载到机器人框架中
- python - 抓取时出现AttributeError
- python - 在 python 中使用正则表达式解析 Web 日志文件
- python - django 从 ProcessedImageField 迁移到 FilerImageField 失败
- xgboost - 以 json 格式可视化 H2o XGBoost 树,找不到丢失的孩子
- ios - 为什么 xcode 不让我创建一个 IBOutlet
- python - 如何对我的 AWS Lambda 函数进行故障排除?
- c - 如何访问在 C 程序中的结构中定义的枚举
- python - Flask Python NameError:未定义名称'Flaskform'
- php - Laravel 从集合中删除模型条目