本文介绍了如何在居中和左对齐之间定位文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要将一些文本居中对齐,但是将其向左推,使其位于居中对齐和左对齐之间.
I need to have some text that is center aligned but pushed to the left so that it is in between center and left aligned.
<th style="text-align:Center"> TextHere</th>
推荐答案
您将需要一个内部元素,该元素是标题单元格宽度的一半且居中.该元素的内容将左对齐.
You'll need an inner element that's half the width of the heading cell and centered. That element's contents will be left-aligned.
table {
width: 100%;
}
th:nth-child(2) {
text-align: center;
background: pink;
}
th span {
display: inline-block;
width: 50%;
text-align: left;
background: lightblue;
}
<table>
<tr>
<th></th>
<th><span>Text Here</span></th>
<th></th>
</tr>
</table>
您要求内联CSS.我将它留给您以迁移到此类.不过,嵌入样式标签可能会更好.
You asked for inline CSS. I'll leave it to you to migrate to such. An embedded style tag might be better, though.
这篇关于如何在居中和左对齐之间定位文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!