根据其他DIV元素对DIV的对齐
我在对齐两个divs中遇到问题,这些div包含在父级内部。这是当前对齐方式的样子:
但是,我希望每个字母都可以对齐每个字母与每个DIV相比,每个DIV都以自己的长度为中心。
这是与图片关联的HTML和CSS。任何帮助将不胜感激!
.inner {
resize:none;
width: 100%;
height: 100%;
background-color: rgb(200, 200, 200);
border-radius: 20px;
align-items: center;
}
.days {
resize:none;
width: 100%;
height: 50%;
display: flex;
justify-content: center;
}
.nums {
resize:none;
width: 100%;
height: 50%;
display: flex;
justify-content: center;
}
<div class="inner">
<div class="days">
</div>
<div class="nums">
</div>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仅使用CSS网格会更容易。
创建一个7列网格,其中:
网格 - 拼写 - 列重复(7,value);
仅具有与列中最大内容一样宽,您可以使用
min-content。
要中心文本,您只需使用``text-align:center''
Would be way easier to just use CSS Grid.
Create a 7 column grid with:
grid-template-columns repeat(7, value);
To have the columns only as wide as the largest content within the column you can use
min-content
.To center the text you just use `text-align: center´