html - 像素中具有相同高度和宽度的元素呈现为非正方形
问题描述
我正在尝试实现一个简单的三个垂直点菜单,但遇到了一些相当奇怪的行为。尽管它们都具有确定的高度和宽度,但这三个点呈现为非正方形,似乎取决于祖父容器的尺寸。我尝试使用px
、rem
、em
和百分比来调整它们的大小,但问题仍然存在。
我还尝试通过显式设置父元素的宽度和高度并将其设置为 flexbox 以及删除父元素和点上的所有填充和边距来放置点,但似乎没有任何东西可以缓解这个问题。代码如下所示:
.grandparent {
display: flex;
width: 100%;
margin-bottom: 10px;
align-items: center;
}
.item1 {
height: 50px;
width: 50px;
margin-left: 15px;
height: 50px;
width: 50px;
position: relative;
}
.item1 img {
border-radius: 50%;
height: 50px;
}
.item2 {
flex: 1 1;
}
.title {
text-align: left;
margin: 0 0 5px 13px;
font-size: 20px;
font-weight: 400;
}
.subtitle {
text-align: left;
margin-left: 13px;
margin-top: -9px;
font-size: 13px;
color: #808080;
}
.parent {
margin-right: 11px;
padding: 5px 8px;
cursor: pointer;
}
.dot {
width: 6px;
height: 6px;
margin-bottom: 4px;
border-radius: 50%;
background-color: #808080;
}
.no-appearance {
appearance: none;
border: 0;
background: none;
}
<div class="grandparent" style="width: 375px; height: 50px">
<div class="item1"><a href="#"><img src="https://picsum.photos/50/50" /></a></div>
<div class="item2">
<div class="title">Example text</div>
<div class="subtitle">Example text</div>
</div>
<button class="parent no-appearance">
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
</button>
</div>
编辑:我在片段中添加了更多代码以尝试重现该问题,但不幸的是,即使它在我的开发环境中始终可以重现,它似乎也无法重现。
下面是当祖父母为 410x50 时如何在 Chrome 88.0 中呈现的示例:
...这是祖父母为 375 x 50 时的样子:
知道这里可能会发生什么吗?
解决方案
html-entie⋮
呢?
https://www.w3schools.com/charsets/ref_html_entities_v.asp
.target {
position: relative;
width: 100%;
margin-bottom: 10px;
}
.target::after {
position: absolute;
right: 0;
top: 0;
font-size: 2em;
color: #808080;
content: '\0022EE';
}
.target:hover::after{
cursor: pointer;
}
<div class="target"></div>
推荐阅读
- html - 文字叠加相对定位
- php - 控制台调用未定义方法 Illuminate\Foundation\Application::where() 中的 Laravel ACL 错误
- python - 如何让 pygame 将单击鼠标识别为单击鼠标?
- postman - allauth rest_freamework CSRF 验证失败。请求中止
- android - 在Android中将变量从父视图传递到子视图
- c# - System.IndexOutOfRangeException: '索引超出了数组的范围。' 当我尝试在 C# 中将 csv 转换为 dataGridView
- java - zip4j ZipFile 到字节数组
- java - 用于存储对象数组列表的二维数组列表或数组列表映射?
- python - Python 脚本无法与 crontab 一起使用
- javascript - 如何仅在 Vue.js 中模糊 svg 背景?