CSS/Bootstrap 将一组按钮放在另一个按钮的顶部(和内部)div

CSS/Bootstrap Place a set of buttons on top (and within) another div

我想将这些按钮与图标按钮放在它们上方的三个图像的顶部。我试过将它们设置为 position: absolute;并使用 z-index 但这会导致按钮不在每个相应图像的顶部对齐,如果我手动定位它们,无论何时调整 window 大小时它们都不再对齐。我想让这些按钮陷入图像所在的 div 中,同时仍然覆盖它们。这可能吗?The image is shown below of what it currently looks like

代码如下:

<div class="imageSection">
<div class="container paddingContainer">
  <div class="row">
    <div class="col-4 borderEraser">
      <img class="imageResize" src="{% static 'webapp/images/srblogthumb.jpg' %}">
      <div class="info">
        <a class="btn btn-dark alignLeft" href="https://sebastianrichardsblog.herokuapp.com/home">View Project</a>
        <a class="btn btn-dark alignRight" href="#">View Code</a>
        <a href="#">
          <img class="iconImage" id="info1" src="{% static 'webapp/images/infoIcon.png' %}">
        </a>
      </div>
    </div>
    <div class="col-4 borderEraser">
        <img class="imageResize" src="{% static 'webapp/images/digitaltwinthumb.jpg' %}">
        <div class="info">
          <a class="btn btn-dark alignLeft" href="https://sebastianrichardsblog.herokuapp.com/home">View Project</a>
          <a class="btn btn-dark alignRight" href="#">View Code</a>
          <a href="#">
            <img class="iconImage" id="info2" src="{% static 'webapp/images/infoIcon.png' %}">
          </a>
        </div>
    </div>
    <div class="col-4 borderEraser">
      <img class="imageResize" src="{% static 'webapp/images/mariopicthumb.jpg' %}">
      <div class="info">
        <a class="btn btn-dark alignLeft" href="https://sebastianrichardsblog.herokuapp.com/home">View Project</a>
        <a class="btn btn-dark alignRight" href="#">View Code</a>
        <a href="#">
          <img class="iconImage" id="info3" src="{% static 'webapp/images/infoIcon.png' %}">
        </a>
      </div>
    </div>
  </div>

和 css:

body {
    background-image: url("images/background2.jpeg");
}

h1 {
    color:aliceblue;
}

.srlogoimage {
    width: 75%;
    height: 75%

}

.hidden {
    display: none;
}

.textCentered {
    text-align: center;
}

.imageResize {
    position: relative;
    width: 98%;
    height: auto;
    display: block;
    margin-left: auto;
    margin-right: auto;
    background-size: cover;
    border-radius: 10%;
    max-height: 100%;
    max-width: 100%;
    
    
}

.borderEraser {
    margin-left: 0px;
    margin-right: 0px;
    border-left: none;
    border-right: none;
    display: block;
    padding-left: 0px;
    padding-right: 0px;
}


.alignRight {
    float: right;
    justify-content: center;
}

.alignLeft {
    float: left;
    justify-content: center;
}

.alignBottom {
    text-align: center;
}



.imageSection {
    position: relative;
    z-index: 0;
}



.info {
    padding: 1%;
    z-index: 9;
}
.iconImage {
    max-height: 10%;
    max-width: 10%;
    border-radius: 50%;
    background-color: aliceblue;
    
   
    

}

.paddingContainer {
    border-color: blanchedalmond;
    border: 50%;
    padding-left: 9%;
    padding-right: 9%;
    
}

任何帮助或指点将不胜感激,我已经坚持了一个星期了

如果您想要实现这样的目标:

您可以添加

.borderEraser {
    position: relative;
}
.info {
    position:absolute;
    top: 50%; 
    left: 0; 
    right: 0; 
    transform: translate(0, 30%); // try different values
}

给你的css-classes。要在图像变小(调整大小时)时更改定位,您可以使用 media-queries 并更改 position-style.

如果您决定使用图像作为背景,您应该使用 flexbox 并相应地对齐按钮。