内联块元素上的 CSS 文本对齐
我有这样的结构:
<div class="father">
This string is left-aligned
<div class="divToCenter" style="display:inline-block;">
//contains other divs.I used inline block for making this div as large as
//content ATTENTION: its width is not fixed!
</div>
</div>
我怎么说:
让我只拥有以“father”div为中心的名为“divToCenter”的类。
谢谢卢卡
I have this structure:
<div class="father">
This string is left-aligned
<div class="divToCenter" style="display:inline-block;">
//contains other divs.I used inline block for making this div as large as
//content ATTENTION: its width is not fixed!
</div>
</div>
How could I say :
Let me have ONLY the class named "divToCenter" centered in "father" div.
Thanks
Luca
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将左对齐的字符串或块向左浮动,然后在内容上使用
overflow:hidden
,它将自动占用剩余空间,您可以按照自己的方式text-align
想。或者将左侧内容也转换为内联块,以便它和内容并排放置,并且您将能够分别对每个内联块进行文本对齐。
Float the left aligned string or block to the left, then with
overflow:hidden
on the content it will automatically take up the remaining space and you cantext-align
it how you want.Either that or convert the left content to an inline block too so it and content are side by side and you will be able to
text-align
eachinline-block
separately.更新:
Update: