将滚动添加到嵌套容器

时间:2016-12-16 22:59:29

标签: html css css3 flexbox

我试图在容器(.widget2)中获取容器(.content)来滚动并保持边框。

由于某种原因,内部容器滚过父容器的底部边缘,滚动条不会呈现。

这是一个表达我所谈论的内容的小提琴: https://jsfiddle.net/ggongon/kcyxz34L/1/



*,
*:before,
*:after {
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
}
#container {
  border: 6px solid red;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  /* position:absolute;
 top:10px; left:10px; right:10px; bottom:10px; */
}
#summary {
  height: 60px;
  border: 2px solid green;
}
#content {
  padding: 10px;
  border: 2px solid blue;
  overflow: hidden;
}
.widget {
  background: gray;
  border-radius: 12px;
  min-height: 30px;
}
.widget2 {
  overflow: auto;
}
.padbottom {
  margin-bottom: 20px;
}

<div id="container">
  <div id="summary">
    header section
  </div>
  <div id="content">
    <div class="widget padbottom">
      widget area
    </div>
    <div class="widget widget2">
      another widget area <br /><br>
      Problem:<br>
      1. this widget area scrolls past the bottom red border<br >
      2. How do i add a scroll in this section only and maintain the 10px padding within the content area <br><br><br>
sdfasfd<br>sdfasfd<br>sdfasfd<br>sdfasfd<br>sdfasfd<br>sdfasfd<br>sdfasfd<br>sdfasfd<br>sdfasfd<br>sdfasfd<br>sdfasfd<br>sdfasfd<br>sdfasfd<br>sdfasfd<br>sdfasfd<br>sdfasfd<br>sdfasfd<br>sdfasfd<br>
sdfasfd<br>sdfasfd<br>sdfasfd<br>sdfasfd<br>sdfasfd<br>sdfasfd<br>sdfasfd<br>sdfasfd<br>sdfasfd<br>sdfasfd<br>sdfasfd<br>sdfasfd<br>sdfasfd<br>
    </div>
     </div>
</div>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

要使# There are other ways to construct these two lists, but this will do. MD := $(wildcard *.md) PDF := $(wildcard *.pdf) PDFROOTS := $(basename $(subst -,.,$(basename $(PDF)))) MDROOTS := $(filter-out $(PDFROOTS), $(basename $(MD))) TARGETS:= $(addsuffix -foo.pdf, $(MDROOTS)) $(PDF) .SECONDEXPANSION: %.pdf: $$(basename $$(subst -,., $$*)).md # perform actions on $< 可滚动,只需将父级设为灵活容器即可。

.widget2

revised fiddle