【发布时间】:2017-08-10 00:51:41
【问题描述】:
我正在尝试制作一个响应式网站。所以,我有一个图像宽度,其宽度由页面的 with 决定,如 sn-p 所示。通常,为了保持纵横比,我只会说:height: relative
但由于某种原因,宽度变小时高度没有调整..这是为什么?
/* TITLE BLOCK */
.title_block {
width: 100%;
min-height: 320px;
height: auto;
}
.title-block-image {
width: 100%;
max-width: 345px;
height: relative;
display: block;
margin: auto;
}
<div id="title_block" name="title_block" class="title_block white">
<div class="float-left">
<img src="{ROOT}img/Camerashop24/logo.jpg" alt="logo" style="height: 135px;" class="title-block-image">
</div>
</div>
对于响应式网站,我使用媒体查询:
@media screen and (max-width: 1100px) {
}
图片的正常设置如下:
.title_block{
width: 1100px;
height: 140px;
margin: auto;
}
.title-block-image{
height: 100px;
width: auto;
}
可能是我必须取消设置 100px 还是什么?还是应该新的height: auto 已经这样做了?
【问题讨论】:
-
css中没有
height: relative! -
你不能只删除 height: relative,然后添加 height: auto;
标签: html css image responsive