【发布时间】:2021-12-30 17:24:00
【问题描述】:
目标
尝试
问题
我正在寻找实现上图所示效果的最佳做法。不确定我是否过度使用 Flexbox,但我的布局中的所有内容要么是层次结构中每一层的 flex 容器(父容器或嵌套容器)。
我需要绝对定位吗?它如何处理响应式更改?
HTML 片段
<div className={styles['admin-panel']} id={styles['management-btn-container']}>
<button className={`${buttons['btn-default']} ${buttons['btn-admin-1']}`}>???? Manage Posts</button>
<div className={`${buttons['test']}`}>
<button className={`${buttons['btn-default']}`}>✍???? Manage Comments</button>
<div className={`${buttons['notification-bubble']}`}>1</div>
</div>
<button className={`${buttons['btn-default']} ${buttons['btn-admin-1']}`}>⏰ Manage Schedules</button>
</div>
按钮 CSS
.btn-default {
border: 2px solid black;
background-color: transparent;
color: white;
padding: 14px 28px;
font-size: 16px;
cursor: pointer;
font-family: 'Lucida Grande';
border: 1px solid grey;
border-radius: 2px;
text-transform: uppercase;
}
.btn-admin-1 {
min-width: 23.33%;
max-width: 33.33%;
}
.btn-admin-1:hover,
.btn-admin-2:hover {
border: 1px solid white;
}
.test {
}
.notification-bubble {
border-radius: 50%;
background-color: red;
border: 2px solid white;
height: 20px;
width: 20px;
position: absolute;
margin-top: -60px;
margin-left: 230px;
}
【问题讨论】:
-
嗨:) 目前尚不清楚尝试和问题之间的问题是什么。尝试看起来不错,您何时/如何遇到问题?
-
这个尝试看起来不错,但我觉得它被破解了。这似乎是因为中间子 div 打破了 flex 流,因为我在那里注入了一个中间 div。我希望崩溃一起发生。
-
您能添加浏览器呈现的相同 HTML 代码吗?从开发者工具复制它。