如何对齐div?

问题描述 投票:0回答:1

我有三张要与display: flex对齐的图像,我看到那些div相互干扰,我只是不能让它们与另一张div并排,所以这些div重叠了。我做了一个JSFiddle来更好地解释它here

这是我的HTML:

<div class="top-section-hover">
  <span class="hover-cover-left">
    <a href="#" class="cover-left-content">
      <img src="https://www.4metri.lv/upload/iblock/95c/95c14a70011a4c90c37656d71c1c7f43.png" alt="" class="cover-img">
      <span class="cover-title">Birojam</span>
    </a>
  </span>

  <span class="hover-cover-middle">
    <a href="#" class="cover-left-content">
      <img src="https://www.4metri.lv/upload/iblock/28e/28e0b8c52db48dd56e0c0bfcccb445ff.png" alt="" class="cover-img">
      <span class="cover-title">Mājai</span>
    </a>
  </span>

  <span class="hover-cover-right">
    <a href="#" class="cover-left-content">
      <img src="http://4metri.lan/public/..\resources\images\4metribildelabi.png" alt="" class="cover-img">
      <span class="cover-title">Pasākumiem</span>
    </a>
  </span>
</div>
</div>

这是我的CSS:

.top-section-hover {
    display: flex;
    padding-top: 10em;
    justify-content: center;
    flex-grow: 2;
    text-align: center;
    text-transform: uppercase;
    font-weight: bold;
    max-width: 96%;
}

.top-section-hover img {
    position: relative;
    top: 0;
    transition: top ease 0.5s;
    left: 0;
}

.top-section-hover img.active {
    top: -30px;
    transition: all 0.5s ease;
}

.cover-title {
    font-weight: bold;
}

.top-section-hover span.active2 {
    color: white;
    border-bottom: 3px solid white;
    transition: 0.5s all;
}

The target

这是理想状态,它们并排排列

html css alignment
1个回答
0
投票
.top-section-hover {
    display: flex;
    padding-top: 10em;
    justify-content: center;
    flex-grow: 2;
    text-align: center;
    text-transform: uppercase;
    font-weight: bold;
    max-width: 96%;
    align-items:center

}
© www.soinside.com 2019 - 2024. All rights reserved.