【发布时间】:2022-01-12 05:26:13
【问题描述】:
所以我觉得我已经尽一切努力让这个按钮进入 div 的底部,但似乎没有任何效果。如果我将容器 div 切换为 align-content: flex-end 一切都将移至底部,但我试图将 div 保持在顶部并且只按下按钮。我正在使用 React 和 CSS 模块。
import styles from './Total.module.css';
const Total = ({ tipTotal, total, handleReset }) => {
return (
<div className={styles.total}>
<div className={styles.totalTipAmount}>
<div className={styles.totalLeft}>
<div className={styles.totalTop}>Tip Amount</div>
<div className={styles.totalBottom}>/ person</div>
</div>
<div className={styles.totalRight}>${tipTotal}</div>
</div>
<div className={styles.toalAmount}>
<div className={styles.totalLeft}>
<div className={styles.totalTop}>Total</div>
<div className={styles.totalBottom}>/ person</div>
</div>
<div className={styles.totalRight}>${total}</div>
</div>
<button className={styles.totalReset} onClick={handleReset}>
RESET
</button>
</div>
);
};
export default Total;
.total {
display: flex;
align-self: center;
flex-direction: column;
width: 80%;
min-width: 80%;
margin: 30px 0;
background-color: var(--Very-dark-cyan);
border-radius: 15px;
padding: 30px 15px 5px 15px;
}
.total div {
display: flex;
justify-content: space-between;
margin-bottom: 10px;
justify-self: flex-start;
}
.totalLeft {
display: flex;
flex-direction: column;
}
.totalTop {
color: var(--White);
font-size: medium;
margin-bottom: 5px !important;
}
.totalBottom {
font-size: small;
color: var(--Dark-blueish-cyan);
}
.totalRight {
font-size: xx-large;
color: var(--Strong-cyan);
}
.total button {
background-color: var(--Strong-cyan);
color: var(--Very-dark-cyan);
font-size: large;
font-weight: 700;
width: 100%;
max-width: 100%;
}
@media (min-width: 900px) {
.total {
height: 100%;
grid-column-start: 2;
grid-row-start: 1;
grid-row-end: 4;
justify-self: center;
}
.total button {
align-self: flex-end;
}
}
【问题讨论】:
标签: html css reactjs flexbox react-css-modules