html - html/css - 如何将关闭按钮放在圆形背景中
问题描述
我正在尝试将 X 完全放在圆圈内,但由于某种原因,我无法让它们相互匹配,请参见下文
html:
<div class="messages">
<span class="closebtn dot" onclick="this.parentElement.style.display='none';">×</span>
{% for message in messages %}
<span><li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li></span>
{% endfor %}
</div>
CSS:
.messages {
position: sticky;
width: 235px;
z-index: 1;
float: right;
border-radius: 1px;
margin: 0 20px;
}
.closebtn {
color: #535353;
font-size: 30px;
cursor: pointer;
position: absolute;
z-index: 1;
margin: -25px 0 0 -10px;
}
.dot {
height: 25px;
width: 25px;
background-color: #bbb;
border-radius: 50%;
display: inline-block;
}
解决方案
.dot
只需在您的课程中添加这个额外的 CSS
.dot {
text-align: center;
line-height: 25px;
}
推荐阅读
- javascript - 无法获取 Angular 材质自动完成值
- reactjs - 如何在jsx反应中访问数组中的数组第一个元素?
- c++ - 弦乐基础
- c# - 我需要自己在 xamarin.forms 中清理内存吗?
- php - Laravel 过滤嵌套关系
- javascript - Javascript Jest 遇到了意外的令牌
- c++ - libcxx std::counting_semaphore 如何为发布/获取实现“强烈发生之前”?
- javascript - 实现 JS 装饰器来包装类
- mysql - ROW_NUMBER() OVER (PARTITION BY ORDER BY)。与“WITH AS”和“WHERE”结合使用以限制结果时的性能?
- javascript - Azure Maps SDK 弹出窗口在初始加载后未打开