显示:表格和文本右对齐不起作用
我有一个像这样的 html 结构:
<div class="campain">
<div class="campainText">
<a href="#"><h2>Ny app til iPhone og iPad</h2></a>
<a href="#"><h2>Tips og vinn</h2></a>
</div>
<div class="campainPicture">
Picture goes here
</div><div class="clear"></div>
</div>
我希望campainText 右对齐。该元素的 css 是这样的:
font-family: 'Spinnaker', sans-serif;
font-size: 17px;
color: #FFFFFF;
background-color: #A2AD00;
display: table;
padding: 4px;
margin: 4px 4px 4px 4px;
text-decoration: none;
我知道 css 的其余部分正在工作。问题是,如果我在显示字段中包含表格选项,文本将左对齐。一旦我删除它,它就会按预期工作。是否有任何解决方法,或者我是否必须使用 display: inline 和
标签?
>
I've got a html-structure like this:
<div class="campain">
<div class="campainText">
<a href="#"><h2>Ny app til iPhone og iPad</h2></a>
<a href="#"><h2>Tips og vinn</h2></a>
</div>
<div class="campainPicture">
Picture goes here
</div><div class="clear"></div>
</div>
And I'd like the campainText to be right-align. The css for this element is this:
font-family: 'Spinnaker', sans-serif;
font-size: 17px;
color: #FFFFFF;
background-color: #A2AD00;
display: table;
padding: 4px;
margin: 4px 4px 4px 4px;
text-decoration: none;
I know that the rest of the css is working. The problem is that the text is left-aligned if I include the table-option in the display-field. As soon as I remove this, it works as expected. Are there any workarounds for this, or do I have to use display: inline and <br />
tags?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
小提琴:http://jsfiddle.net/xbNCZ/
“表格 +
文本-align:right
不起作用”,因为默认情况下表格元素不会拉伸到完整宽度。添加width:100%
以获得所需的结果。设置前 / 设置后
宽度:100%
。Fiddle: http://jsfiddle.net/xbNCZ/
"Table +
text-align:right
does not work", because a table element doesn't stretch to the full width by default. Addwidth:100%
to get the desired result.Before / After setting
width:100%
.