Flex Column 强制隐藏 flexbox 的初始项

Flex Column forcibly hides the initial items of the flexbox

我有一个侧边栏,它是使用 FlexBox 列布局构建的,如下所示:

.SideBarContainer {
  // flex-grow: 1;
  width: 100%;
  height: 100%;
  // display: flex;
  // flex-direction: column;
  padding: 0.5rem 1rem;
  align-items: center;
  justify-content: space-evenly;
  overflow-y: auto;
  overflow-x: hidden;
  font-family: $font-family;
}

看起来像:

这是我注释掉 flex 布局的时候(理想情况下我想保留它)。但是当我启用 flex 布局时,如下所示:

.SideBarContainer {
  // flex-grow: 1;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0.5rem 1rem;
  align-items: center;
  justify-content: space-evenly;
  overflow-y: auto;
  overflow-x: hidden;
  font-family: $font-family;
}

出于某种原因,它强制将图像移动到顶部并且无法滚动到视图:

一种方法是摆脱 flexbox 并以某种方式将项目居中对齐,但我更感兴趣的是了解如何使用 FlexBox 实现相同的效果,以及究竟是什么推动图像在 flexbox 时被切断已应用。

我已经为您创建了这个 html 代码和 CSS:

.main {
  width: calc(100%/3 + 60px);
  font-family: 'Jost', sans-serif;
}

.SideBarContainer {
  display: flex;
  flex-direction: column;
}

.name {
  margin: 0;
  font-size: 30px;
}

.desig {
  color: #bcbcbc;
  font-weight: 600;
}

.profile-img {
  border-radius: 100%;
  height: 100px;
  width: 100px;
  object-fit: cover;
}

.btn {
  background-color: #f5f5f5;
  color: #000000;
  display: inline-block;
  text-align: center;
  text-decoration: none;
  font-size: 16px;
  padding: 4px 20px;
  margin: 10px 0;
  width: fit-content;
  box-shadow: 0 0 5px 0 rgb(0 0 0 / 20%);
}

.btn.dark {
  background-color: #000;
  color: #f3ff26;
  text-transform: capitalize;
  font-weight: 400;
  font-size: 18px;
  width: calc(100% - 60px);
  border-radius: 8px;
  box-shadow: 0 0 5px 0 rgb(0 0 0 / 20%);
}
<div class="main">
  <div class="SideBarContainer">
    <img src="https://via.placeholder.com/150x150" class="profile-img" />
    <h6 class="name">Rampy sharma</h6>
    <span class="desig">Individual Singer</span>
    <a href="javscript:void(0);" class="btn">Edit</a>
    <p>It is a long established fact that a reader will be distracted by the readable that it has a more-or-less normal distribution of letters, as opposed to using 'Content here.</p>
    <a href="javscript:void(0);" class="btn dark">portfolio</a>
  </div>
</div>