我想将我的按钮对齐在我的输入下方,我将它们都放在一个名为card-group的div中。我在两个元素上都有width: auto;
。我正在使用媒体查询使其适合移动设备,但我无法使用它。输入和按钮不会在彼此下方对齐。 Here是一个工作范例的小提琴。
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>
的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 {
}
}
答案 0 :(得分:5)
在媒体查询中添加:
from django.conf.urls import url ,include
from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
url(r'^ReportsData/', include('Reports.urls')),
]
if settings.DEBUG :
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)
它将改变弹性行为并使弹性项目对齐为一列而不是一行。
答案 1 :(得分:0)
如果你想保持一切相对而且完全灵活,那么Ganor的方法是有效的。或者,您可以执行以下操作:
@media (min-width: 600px) {
.btn-postnl {
position: absolute;
margin: 60px 0px;
}
}
请注意,如果您希望保留以前的布局并且仅在满足某个设备像素宽度时应用更改,您也可以使用@media和Itay的方法来使用此方法。