css - 如何在 CSS 中设置 height auto 的最大高度?

标签 css

我想为 div 设置最大高度,就像在代码中一样设置高度自动。

.background.left-sidebar {
  height: auto !important;
  padding-bottom: 0;
  right: 0;
  width: 300px;
  background-color: #999999;
  margin-top: 40px;
  margin-right: 300px;
}

.left-sidebar {
  height: auto;
  width: 300px;
  padding-bottom: 0px;
}

.left-sidebar-top {
  width: 100%;
  height: 300px;
  background-color: #996699;
}

  <div class="right_block left-sidebar">
    <div class="content">
      <div class="top_block left-sidebar-top">
        <div class="content">
        </div>
      </div>
      <div class="marker">This</div>
    </div>
  </div>

我尝试设置height:100%height:auto,但不起作用。

如何在 CSS 中设置 height auto 的最大高度?

Plunker

最佳答案

你可以尝试:

height : 100vh;

将您的 div 设置为视口(viewport)的 100%

关于css - 如何在 CSS 中设置 height auto 的最大高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39163244/

相关文章:

javascript - 向这个 jQuery 脚本添加动画

css - 网站首页解析问题

javascript - 如何修复背景颜色的 CSS 切换?

css - 基于窗口宽度的div垂直位置

html - 如何使用 rails 调用修复困惑的页面?

jquery - 从某些按钮/输入中排除 jquery ui 样式

html - 减少 Bootstrap 中两行导航栏之间的空间

css - CSS 的嵌套选择器在 IE8 中不起作用但在 IE6 中起作用?

html - 是否可以在 Notepad++ 中为 2 种语言设置自动完成?

css - 将空间分成3个平行 block