对齐新行上的项目

Luc*_*ser 0 html css flexbox

我想将我的按钮对齐在我的输入下方,我将它们都放在一个名为card-group的div中.我有两个元素a width: auto;.我正在使用媒体查询使其移动友好,但我不能让它工作.输入和按钮不会相互对齐.是一个工作实例的小提琴.

HTML

<div class="card-zipcode">
    <label>Postcode</label>
    <div class="card-group">
        <input type="text" class="input-zipcode">
        <button class="btn-postnl" id="bekijken" type="submit">Bekijken</button>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS

.card-group {
display: flex;
justify-content: space-between;
}

.card-group input {
width: auto;
}

.btn-postnl {
display: inline-block;
position: relative;
height: 40px;
width: auto;
margin: 0;
padding: 0 20px;
vertical-align: top;
border: 1px solid rgba(0, 0, 0, 0);
background-color: #ED8C00;
-webkit-appearance: none;
outline: 0;
line-height: 38px;
font-size: 1em;
font-weight: 300;
color: #FFF;
cursor: pointer;
-webkit-transition: all .1s ease-out 0s;
transition: all .1s ease-out 0s;
border-radius: 3px;
}

@media only screen and (max-width: 400px) {
body {
    background-color: #fff;
}

.card {
    box-shadow: none;
    margin-top: -1px;
}

.card-group {

}
}
Run Code Online (Sandbox Code Playgroud)

Ita*_*nor 5

在媒体查询中添加:

.card-group {
    flex-direction: column;
}
Run Code Online (Sandbox Code Playgroud)

它将更改弹性行为并使弹性项目对齐为列而不是行.

的jsfiddle