我的页面上有一个简单的模式,当我调整浏览器的大小时,它会调整到它的大小,问题是当浏览器说“高度”时。在模态元素上,顶部位似乎是“走出去”。浏览器,所以基本上你不能看到那部分..
我尝试在Date, Product, Qty
1 Jan 2017, A, 10
2 Jan 2017, A, 15
2 Jan 2017, B, 25
2 Jan 2017, C, 50
3 Jan 2017, B, 10
4 Jan 2017, P, 25
4 Jan 2017, Q, 35
4 Jan 2017, R, 60
4 Jan 2017, S, 15
和overflow
上设置max-height
和#content-container
,但它完全无效,我做错了什么?
jsfiddle:https://jsfiddle.net/kmav8ox7/
HTML:
#wrapper
CSS:
<div id="content-container">
<div id="wrapper">
<ul id="flex-container">
<li class="flex-item">
<div id="list-area"></div>
</li>
<li class="flex-item">
<div id="img-desc-container">
<div class="image-area">
<img src="http://dukes-lancaster.org/wp-content/uploads/2014/11/placeholder.jpg">
</div>
<div class="description-area"></div>
</div>
</li>
</ul>
</div>
</div>
答案 0 :(得分:1)
这可能会对你有所帮助。
您需要更改#content-container
的某些CSS。将translate(-50%, 50%)
更改为translate(-50%, 0%)
并删除margin-top
/* center content */
body {
display: flex;
align-items: center;
min-height: 100vh;
}
#content-container {
width: 50%;
height: 50%;
border: 3px solid red;
margin-left: 50vw;
transform: translate(-50%, 0%);
}
/* wrapp content */
#wrapper {
width: 100%;
height: 100%;
margin: 0;
/*Centering content*/
display: inline-flex;
justify-content: center;
align-items: content;
}
#img-desc-container {
display: flex;
flex-direction: column;
}
/* MULTI ELEMENT */
.image-area,
.description-area {
width: 200px;
height: 125px;
border: 1px solid black;
}
.image-area,
.description-area,
#list-area {
box-sizing: border-box;
margin: 10px;
}
/* LIST AREA */
#list-area {
width: 200px;
height: 250px;
border: 1px solid black;
background-color: #22AED1;
float: left;
}
/* IMG AREA */
.image-area {
background-color: #016FB9;
}
.image-area img {
width: 100%;
height: 100%;
}
/* DESC AREA */
.description-area {
background-color: #AFA98D;
height: 105px;
}
/*FLEX CONTAINER */
#flex-container {
padding: 0;
margin: 0;
list-style: none;
display: flex;
-webkit-flex-flow: row wrap;
justify-content: space-around;
}
&#13;
<div id="content-container">
<div id="wrapper">
<ul id="flex-container">
<li class="flex-item">
<div id="list-area"></div>
</li>
<li class="flex-item">
<div id="img-desc-container">
<div class="image-area">
<img src="http://dukes-lancaster.org/wp-content/uploads/2014/11/placeholder.jpg">
</div>
<div class="description-area"></div>
</div>
</li>
</ul>
</div>
</div>
&#13;
答案 1 :(得分:0)
我认为您可以使用此css代码进行解决。
#content-container {
width: 50%;
height: 50%;
border: 3px solid red;
margin-top: 0;
margin-left: 50vw;
transform: translate(-50%, 0%);
}
#wrapper {
width: 100%;
height: 94vh;
margin: 0;
display: inline-flex;
justify-content: center;
align-items: content;
overflow: auto;
}
答案 2 :(得分:0)
为了使其响应,您必须避免使用像素来提供高度或宽度。 你可以给出百分比高度(例如,最大值为100%),然后它永远不会离开页面