html - 尽管是 inline-block,但元素表现得像块
问题描述
我希望我priority-menu
的(有 2 个点的)水平显示 3 个点。由于每个单独的点都是inline-block
我不明白为什么它们堆叠在一起。通过单击“保存任务”按钮右侧的蓝色圆圈来呈现菜单,这会将其显示更改为inline
而不是none
。我尝试将其更改为inline-block
,但似乎没有任何改变。
/* The popup menu - hidden by default */
#priority-menu {
display: none;
position: absolute;
top: 150%;
border: 3px solid #f1f1f1;
z-index: 9;
max-width: 300px;
padding: 10px;
background-color: white;
}
#priority-dot-open-menu {
position: relative;
height: 25px;
width: 25px;
background-color: blue;
border-radius: 50%;
display: inline-block;
opacity: 0.8;
cursor: pointer;
}
#priority-dot-open-menu:hover {
opacity: 1;
}
#priority-dot-blue {
height: 25px;
width: 25px;
background-color: blue;
border-radius: 50%;
display: inline-block;
opacity: 0.8;
}
#priority-dot-yellow {
height: 25px;
width: 25px;
background-color: yellow;
border-radius: 50%;
display: inline-block;
opacity: 0.8;
}
#priority-dot-red {
height: 25px;
width: 25px;
background-color: red;
border-radius: 50%;
display: inline-block;
opacity: 0.8;
}
.modal-footer {
padding: 0;
}
#priority-menu::after {
content: " ";
position: absolute;
bottom: 100%; /* At the top of the tooltip */
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent transparent black transparent;
}
<div class="modal-footer d-flex flex-row justify-content-start pl-0 mt-4 border-0">
<button type="button" class="btn btn-primary btn-sm" id="add-task-modal-save">Save task</button>
<span id="priority-dot-open-menu">
<span id="priority-menu">
<span class="tooltip-top"></span>
<span id="priority-dot-blue"></span>
<span id="priority-dot-yellow"></span>
<span id="priority-dot-red"></span>
</span>
</span>
</div>
解决方案
您priority-menu
包含在您设置为 25px 宽度的元素中。尝试删除它并更改为 300 像素,例如您的priority-menu
.
#priority-dot-open-menu {
position: relative;
height: 25px
width: 300px;
background-color: blue;
border-radius: 50%;
display: inline-block;
opacity: 0.8;
cursor: pointer;
}
您也可以尝试将声明添加width
到菜单中,而不仅仅是max-width
.
#priority-menu {
width:300px;
}
推荐阅读
- c++ - 我怎样才能简化这个程序?
- sql - 如何在不等于,NOT IN的情况下重写查询?
- ruby - Vim 使用哪个 Ruby 来执行 :ruby 命令?
- firebase - flutter firebase firestore: How to get images stored in array firestore?
- python - 如何从矢量方向拍摄
- python - Python:在为同一项目调用 send_hook Discord 之前等待一段时间
- typescript - TypeScript 中缺少全局 Promise
- javascript - 如何从上一页调用的函数更改新页面的内部内容?
- java - 如何在 AnyLogic 中计算立方体和函数?
- python - 确定列表中元素数量的第一个数字(Python)