2015-10-06 59 views
0

Fiddle here.对齐Flexbox的

我试图粘白色插入符号(^)至.section-1底部,水平居中内部,但在最底层在容器的底部的元件。正如您所看到的,插入符号本身位于Bootstrap container-fluid内,其本身位于柔性盒内(通过vertical-center类应用)。

我试图用margin和传统定位bottom: 0;等无济于事。同样,flex-end财产不按我的想法工作。欢迎所有的解决方案和建议,只要他们继续使用柔性盒。

回答

1

您可以使用嵌套的柔性容器做到这一点。

HTML

<!-- one adjustment; add span --> 
<div class="align-me-center"><span>Here is some centered text.</span></div> 

CSS

/* ADJUSTMENT TO RULE */ 

.section-1 { 
    min-height: 500px; 
    background-color: #0099cc; 
    height: 500px; /* necessary for child div with percentage height to work; 
         min-height overrides height, so no worries */ 
} 

/* NEW RULES */ 

.container-fluid { 
    display: flex; /* establish nested flex container */ 
    flex-direction: column; 
    height: 100%; /* use full height of container */ 
    justify-content: center; /* position flex items at opposite end of container */ 
} 

.align-me-center { 
    display: flex; /* nested flex container to center flex item (span) */ 
    align-items: center; 
    justify-content: center; 
    height: 100%; 
} 

DEMO:http://jsfiddle.net/b26j5m6t/3/

+0

这是接近的,但我还是想插入符号上方的文字垂直居中。 – daveycroqet

+1

再一次调整。完成。 http://jsfiddle.net/b26j5m6t/3/ –

+1

这正是我想要做的。完善! – daveycroqet