html - CSS 全高响应式网站

标签 html css

我正在尝试创建一个全高响应式网站,该网站具有固定高度的粘性页脚且无滚动。到目前为止我有这个......

body, html {
  height:100%;
  width:100%;
  padding:0;
  margin:0;
}

.content {
  text-align:center;
  background:wheat;
  height:calc(100vh - 100px);
 }
 
 .image_container img {
   max-width:100%;
   height:auto;
 }

footer {
  position:fixed;
  bottom:0;
  height:100px;
  background:teal;
  width:100%;
  color:white;
  text-align:center;
}
<div class="container">

<div class="content">
    This is the content
    <div class="image_container">
      <img src="https://dummyimage.com/500x1000/500/fff">
    </div>
</div>
<footer>This Is The Footer</footer>

</div>

图像导致所有内容滚动,我怎样才能使这个图像高度响应?

最佳答案

这可能有帮助

body, html {
  height:100%;
  width:100%;
  padding:0;
  margin:0;
}

.content {
  text-align:center;
  background:wheat;
  height:calc(100vh - 100px);
 }
 
 .image_container img {
   max-width:100%;
   
 }
 .image_container{
 height:100%;
 }

footer {
  position:fixed;
  bottom:0;
  height:100px;
  background:teal;
  width:100%;
  color:white;
  text-align:center;
}
img{
max-height:100%;
}
<div class="container">

<div class="content">
    This is the content
    <div class="image_container">
      <img src="https://dummyimage.com/500x1000/500/fff">
    </div>
</div>

<footer>This Is The Footer</footer>
</div>

关于html - CSS 全高响应式网站,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46342717/

相关文章:

javascript - react 设置具有特定类名的元素的最小高度属性

html - 在圆形图像周围添加一个圆圈

java - J汤 |获取部分 HTML

html - 如何将旋转的 div 定位为彼此完全齐平

html - 'transform3d' 不适用于位置 : fixed children

CSS : W3 : Transparancy

css - 调整 django 表单 - 评论表单 CSS

javascript - 如何从选择中删除和恢复选项?

html - 为什么字体 Awesome 在发送 marketo 电子邮件时不起作用

html - 浏览器渲染能力、限制和标准