html - 使用 height: auto 拉伸图像。这个有什么替代品?
问题描述
我开发了一个网站,该网站在最新的 Chrome 版本 75.0.3770.142 中运行良好,而旧版本无法正确呈现,即图像被垂直拉伸。
我用过height:auto
。同样的问题出现在 Opera、Safari 和 IE 中。Mozilla 的最新更新往往运行良好。但是旧版本给出了同样的问题。
请帮帮我。我将父元素的高度设置为自动(与下面显示的媒体查询相同),并且我使用了 flexbox 来居中图像。
@media only screen and (max-width: 414px){
#firstsec{
padding-top: 50px;
padding-bottom: 30px;
height: auto;
text-align: center;
background: url(aliali1.png);
background-size: cover;
background-repeat: no-repeat;
}
#firstsec h1{
font-size: 34px;
padding-bottom: 4px;
}
#firstsec #headerdesign img{
padding-top: 30px;
width:200px;
height:auto;
}
<section id="firstsec" class="parallax col-12">
<div id="headerdesign" class="d-flex justify-content-center col-12">
<img class="col-12 hello" src="https://i.stack.imgur.com/vnaKJ.png" alt="Cannot Load Image">
</div>
<div class="d-flex justify-content-center col-12 animated tada"><h1>“Hello this is Ali!"</br>I'm an Engineer & i like Designing</h1></div>
<button class="button button4 animated flash"><a href="#secondsec">Check out my work !</a></button>
</section>
解决方案
只需将样式表中的 align-items:center 属性添加到现有的引导类属性中,因为默认情况下它的 align-items:stretch。下面的例子;
.justify-content-center{
align-items: center;
}
<div class="col-lg-4 d-flex justify-content-center">
</div>
推荐阅读
- google-maps-api-3 - 将 Reactive Maps 与 Google maps Javascript Api 一起使用时出错
- javascript - 是否有一个模式的名称,当新的操作开始时,先前的异步操作会被自动取消?
- javascript - 如何更新 React 组件的渲染数据?
- r - 拆分通过网络抓取构建的 tibble() 的内容
- php - 给所有使用 MySQL 的朋友的最新消息
- python - 读取字符串列表中的空格
- python - Anaconda 环境中的导入问题 [错误 193]
- python - 如何将xml文件数据导入csv?
- git - 获取合并提交的 git diff 输出结果
- php - 如何显示对应于特定 $_SESSION 变量的条目