【发布时间】:2016-10-26 11:56:27
【问题描述】:
我在图像滑块的每一侧都有 div 箭头按钮,我希望它们垂直对齐,并且两者都对齐到它们各自的 div 侧,左箭头对齐到其 div 的左侧,右箭头对齐到右侧它的分区。我的问题是,当我使用float:right 和line-height 时,箭头的图像正确垂直对齐,但按钮未垂直对齐。
这是我的html:
<div class="row">
<div class="large-1 columns arrow">
<div class="button tertiary previous">
<img src="{{ asset('/img/left-arrow.svg') }}" />
</div>
</div>
<div class="large-10 columns">
<div class="swiper-container">
<div class="swiper-wrapper">
@foreach($issues as $issue)
<div class="swiper-slide">
<img
src="/imagecache/large/{{ $issue->first()->image }}"
onclick="magazineDetail(
'{{ $issue->first()->magazine->id }}',
'{{ $issue->first()->magazine->name }}',
'{{ $issue->first()->magazine->summary ?: '' }}',
'{{ $issue->first()->magazine->image ?: '' }}',
'{{ $issue->first()->image }}'
)"
>
</div>
@endforeach
</div>
</div>
</div>
<div class="large-1 columns arrow">
<div class="button tertiary next">
<img src="{{ asset('/img/right-arrow.svg') }}" />
</div>
</div>
</div>
这是我的 scss:
ul {
&.button-group {
margin-left: 0;
li:first-child {
width: 30%;
}
li:not(:last-child) {
margin-right: .7rem;
}
}
}
.button {
text-decoration: none;
line-height: inherit;
&:focus {
outline: none;
background-color: none;
}
&:active {
box-shadow: 0 0 0 0 transparent;
}
&.primary {
background-color: $purple;
color: $white;
&:hover {
background: rgba($purple, 0.4);
}
}
&.secondary {
background-color: $white;
border-color: $black;
color: $black;
&:hover {
background: $white;
border-color: $light-gray;
color: $black;
}
}
&.tertiary {
background: transparent;
border-color: $white;
color: $white;
height: 100%;
font-size: 1.1rem;
padding: .4rem;
&:active {
background: $white;
color: $black;
}
}
&.narrow {
padding-left: 2.2em;
padding-right: 2.2em;
}
&.expand {
width: 100%;
}
}
.carousel {
margin-top: 10%;
.carousel-nav {
text-align: right;
}
.featured-magazines {
margin-top: $global-margin;
}
.button.tertiary {
height: 40px;
line-height: normal;
&.next {
vertical-align:middle;
float:right;
line-height: 200px
}
}
.all {
margin-top: 30px;
width: 100%;
}
.swiper-container{
text-align: center;
}
.arrow {
line-height: 200px;
}
}
【问题讨论】:
-
垂直对齐仅适用于
inline或inline-block元素,不适用于浮动。如果您的问题与此无关,请发回您输出的代码,而不是上面的开发代码 - 它会更容易调试。