使柔性项目90%宽

时间:2015-03-06 16:39:04

标签: css css3 flexbox

这是一个简单的问题。我一定是错过了答案。我有一个Flex容器,里面有一个flex项目。我希望弹性项目的宽度为90%,并且垂直和水平居中。我只是不能让它达到90%宽。我很困惑。这是我的代码:

<div class="" id="popupContainer">
    <div class="flex-item-popup" id="popup">

    </div>
</div>

    #popupContainer {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    display:flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-content: flex-start;
    align-items: center;
}
#popup {
    width: 90%;
    height: 90%;
    flex-grow: 1;
    flex-shrink: 0;
    flex-basis: 200px;
    justify-content: center;    
    display: -webkit-box;
    display: -webkit-flex;
    display: -moz-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-flex-align: center;
    -ms-flex-align: center;
    -webkit-align-items: center;
    align-items: center;
    background-color: black;
    justify-content: center; /* align horizontal */
    align-items: center; /* align vertical */
}

1 个答案:

答案 0 :(得分:0)

删除这两个,它将正常工作:

flex-grow: 1; flex-basis: 200px;

<强> Live Demo