html - 如何对齐对话框角材料内右上角的按钮?
问题描述
我想在对话框角材料内的右上角对齐按钮。问题是我在按钮和对话框角落之间有一些空间,我不想要它。
这是我的html代码:
<button #btnClose mat-button class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
这是我的CSS代码:
.close {
color: black;
opacity: 1;
max-width: 2vw !important;
min-width: 2vw !important;
}
我可以在 css 中用边距做一些“技巧”,但我认为这是个坏主意:
.close {
color: black;
opacity: 1;
max-width: 2vw !important;
min-width: 2vw !important;
margin: -1.2vw -1.2vw;
}
然后我得到了我想要的:
有更好的解决方案吗?PS:它必须是响应式的。
解决方案
如果要对齐右上角的内容,可以使用:
.close {
position: absolute;
top: 0;
right: 0;
}
推荐阅读
- android - Android Gradle 3.0.0 - 添加特定风格的库依赖项
- c# - 如何在人脸检测过程中暂停秒表?
- c# - C# LibCurlNet 图像上传
- python - 在python中识别列表中的常见元素
- java - JasperException 使用 www.springframework.org/tags/form
- c++ - 在 OpenMP C++ 中使用并行块时没有看到任何显着的改进
- python-2.7 - 我的图像完全是黑色的,它没有显示 50% 黑色和 50% 白色
- elasticsearch - Elasticsearch 启动失败:需要 CONFIG_SECCOMP 和 CONFIG_SECCOMP_FILTER
- android - 在高于 6.0 的操作系统版本中隐藏 Actionbar 时的空白?
- javascript - 减少变化的价值