放弃使用CSS,无法在div的漫游器上放置一个简单的按钮

问题描述

我有两个div,我希望一个按钮位于div的底部。我尝试了所有在网上看到的内容。什么都行不通!

html:

<ion-col >
          <div id="secondCol">
          <ion-text> {{card.cardPoints}} = {{card.cardValue}} € </ion-text>
<!--          <ion-text>{{userPercentageCards[i]}} %</ion-text>-->
            <div id="useButton">
              <ion-button  *ngIf="userPercentageCards[i] >=100" style="bottom: 0"> Usar Cartão!</ion-button>
            </div>

          </div>
        </ion-col>

css:

#secondCol{
 position: absolute;
  width: 100%;
  height: 100%;
}

#useButton{
   position: relative;

  bottom: 0;
 }

我希望按钮位于div的底部,但它不会停留在同一位置,而无需更改。

我几乎要放弃CSS,我讨厌这个!

解决方法

尝试一下:;)

#secondCol{
  position: relative;
  width: 100%;
  height: 100%;
}

#useButton{
  position: absolute;
  bottom: 0;
 }
,

将父元素设为相对,子元素设为绝对:

#secondCol {
    position: relative;
    width: 100%;
    height: 100%;
}
#useButton {
    position: absolute;
    bottom: 0;
}