弹性框垂直居中对齐问题(对齐项目:居中)

Problem with flex-box vertical align middle (align-items: center)

我希望导航箭头垂直居中。

live site 上它们偏离了中心。

存在妥协 CSS 我无法更改为箭头设置 top: 40% (.owl-nav button)。

我试过 unset他们的顶部,但这会将他们推到图像下方。

我试过设置 top: calc(50% - 37.5px);(减去按钮高度 75px 的一半),但这是偏离中心的。我的数学在这里吗?

我已经能够通过为 .owl-nav.pp-carousel-nav 使用固定高度来让它在下面工作,但是在 live page.owl-items 不是固定的宽度和高度,它们反应灵敏。

.owl-carousel .owl-stage {
  position: relative;
}
.pp-content-post-carousel {
  position: relative;
}
.landscape-carousel-container {
  width: 100%;
}
.landscape-carousel-content {
  width: 100%;
}
.landscape-carousel-overlay {
  position: absolute;
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  width: 100%;
  height: 236px;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  -ms-flex-pack: center;
  justify-content: center;
  -webkit-box-align: center;
  -webkit-align-items: center;
  -ms-flex-align: center;
  align-items: center;
  opacity: 0;
  transition: .4s ease !important;
  border-radius: 15px;
  background-color: #22a1d9;
}
.landscape-carousel-img {
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  height: 236px;
  margin-bottom: 10px;
  padding-bottom: 0px;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  -ms-flex-pack: center;
  justify-content: center;
  -webkit-box-align: center;
  -webkit-align-items: center;
  -ms-flex-align: center;
  align-items: center;
  background-color: rgba(14,34,129,0);
  background-image: url("https://cdn-ehbod.nitrocdn.com/MnwLQZiWrxfKgQoPapfeSJHycGHMrPjW/assets/static/optimized/rev-315e7f6/img/background-image.svg");
  background-position: 50% 50%;
  background-size: cover;
  background-repeat: no-repeat;
  -webkit-transition: all 200ms ease;
  transition: all 200ms ease;
  cursor: pointer;
  border-radius: 15px;
  border: 3px solid #dfefef;
}
.owl-nav.pp-carousel-nav {
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  -webkit-align-items: center;
  -ms-flex-align: center;
  align-items: center;
  height: 242px;
  width: 370px;
  position: absolute;
  top: 10px;
}
.owl-nav button {
  position: absolute;
  line-height: 1;
  margin: 0;
  font-size: 20px;
  background: none !important;
  z-index: 1;
  border: none;
  background-color: transparent;
}
.owl-nav button.owl-prev {
  left: -15px;
}
.owl-nav button.owl-next {
  right: -15px;
}
.owl-nav button svg {
  width: 51px;
  height: 51px;
  color: white;
  padding-top: 10px;
  padding-right: 10px;
  padding-bottom: 10px;
  padding-left: 10px;
}
.sr-only {display: none;}
<div class="owl-item cloned" style="width: 370px;">
  <div class="pp-content-post pp-content-carousel-post pp-grid-custom post-6474 templates type-templates status-publish hentry templatecategory-hospitality templatecategory-landscape-liquor-hospitality-2 templatecategory-liquor" itemscope="" itemtype="https://schema.org/CreativeWork" data-id="6474" style="visibility: visible; height: 269.2px;">
    <div class="landscape-carousel-container">
      <div class="landscape-carousel-content">
        <div class="landscape-carousel-overlay">
          <a href="https://mandoemedia.com/templates/hospitality/liquor/liquor-store-many-bottles-templates/" class="landscape-carousel-button w-button" rel="nofollow">Edit this Template</a>         </div>
        <div style="background-image: url(&quot;https://cdn-ehbod.nitrocdn.com/MnwLQZiWrxfKgQoPapfeSJHycGHMrPjW/assets/static/optimized/rev-315e7f6/wp-content/uploads/2021/06/landscape_Hospitality_Liquor_001.jpg&quot;);" class="landscape-carousel-img lazyloaded" nitro-lazy-bg="https://cdn-ehbod.nitrocdn.com/MnwLQZiWrxfKgQoPapfeSJHycGHMrPjW/assets/static/optimized/rev-315e7f6/wp-content/uploads/2021/06/landscape_Hospitality_Liquor_001.jpg"></div>
        <div>Liquor Store - Many Bottles</div>
      </div>
    </div>
  </div>
</div>
<div class="owl-nav pp-carousel-nav">
  <button type="button" role="presentation" class="owl-prev">
    <svg aria-hidden="true" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 192 512">
      <path fill="currentColor" d="M25.1 247.5l117.8-116c4.7-4.7 12.3-4.7 17 0l7.1 7.1c4.7 4.7 4.7 12.3 0 17L64.7 256l102.2 100.4c4.7 4.7 4.7 12.3 0 17l-7.1 7.1c-4.7 4.7-12.3 4.7-17 0L25 264.5c-4.6-4.7-4.6-12.3.1-17z" class=""></path>
    </svg>
    <span class="sr-only">Previous</span>
  </button>
  <button type="button" role="presentation" class="owl-next">
    <svg aria-hidden="true" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 192 512">
      <path fill="currentColor" d="M166.9 264.5l-117.8 116c-4.7 4.7-12.3 4.7-17 0l-7.1-7.1c-4.7-4.7-4.7-12.3 0-17L127.3 256 25.1 155.6c-4.7-4.7-4.7-12.3 0-17l7.1-7.1c4.7-4.7 12.3-4.7 17 0l117.8 116c4.6 4.7 4.6 12.3-.1 17z" class=""></path>
    </svg>
    <span class="sr-only">Next</span>
  </button>
</div>

buttonheight 是 66px,相对于 divclass="pp-content-post-carousel pp-equal-height clearfix" 的位置比图像高 33.19px。

这里是评论中的答案:

问题是由导航元素父框引起的。它还包括下面的文本 - 因此,您不会将它相对于图像居中,而是相对于图像及其描述性文本居中。由于您可能无法在此处更改 html 结构,因此我建议您只需将 css 计算更改为

top: calc(50% - 45px);