【发布时间】:2015-12-08 13:09:23
【问题描述】:
我需要创建简单的图像框 js 控件的标记。 它应该具有主图像容器以及缩略图图像区域。最后一个应该位于主图像区域的顶部、底部、右侧或左侧。
我几乎用“flex”方法完成了标记。 当缩略图区域是水平的(位于顶部或底部)时效果很好:
但对于垂直缩略图区域(主图像左侧或右侧)的情况,它会失败:“thumbs-container”div 溢出,而我希望“thumbs”div 溢出。这是我的测试标记:
<div class="frame" style="height: 250px; width: 250px; border: 1px solid black;">
<div class="image" style="background:red; margin:5px;"></div>
<div class="thumbs-container" style="margin:5px;">
<div class="back" style="background:orange"></div>
<div class="thumbs" style="background:blue;">
<div class="thumb" style="background:green; margin:3px;"></div>
<div class="thumb" style="background:green; margin:3px;"></div>
<div class="thumb" style="background:green; margin:3px;"></div>
<div class="thumb" style="background:green; margin:3px;"></div>
<div class="thumb" style="background:green; margin:3px;"></div>
<div class="thumb" style="background:green; margin:3px;"></div>
<div class="thumb" style="background:green; margin:3px;"></div>
<div class="thumb" style="background:green; margin:3px;"></div>
</div>
<div class="forth" style="background:orange"></div>
</div>
.frame {
display: flex;
flex-flow: row;
}
.image {
flex: 1 0 auto;
order: 0;
}
.thumbs-container {
flex: 0 0 40px;
display: flex;
flex-flow: column;
order: 1;
}
.back{
flex: 0 0 30px;
}
.forth{
flex: 0 0 30px;
}
.thumbs {
flex: 1 0 auto;
display: flex;
flex-flow: column;
justify-content: center;
overflow: hidden;
}
.thumb {
flex: 0 0 30px;
}
【问题讨论】:
标签: javascript html css flexbox