开发者

Can I use the display:inline with text-align: right?

Exam开发者_如何学Pythonple:

<td>
  <img src="..." />
  <img src="..." />
  <div style="text-align:right display:inline;">
    hello world!
  </div>
</td>


Well technically you can but it will have no effect. Display: inline will display the div as an inline element (like an a or span) and therefore not have a width - it will shrink to fit the text.

If you are trying to display inline text on the right try using float: right;

Also, in your code you missed out an ";" after the text-align: right.


You can wrap the element which you want to have display:inline inside another div with dir="rtl"

<div dir="rtl">
  <div style="display: inline">Align to the right</div>
</div>

Demo: https://jsfiddle.net/guya/xwhodc0s/


The spec is somewhat unclear on this, but it shouldn't work. The text-align property doesn't really make sense on inline elements, since it applies to blocks of text (which inline elements are not). In your example, <p> (a block element) would be a better choice anyway.


No, but try using display:inline-block; See snippet

.img{
display:inline-block;
}

.text{
display:inline-block;
color:white;
font-size: 15px;
font-family: tahoma;
text-align:right;
}

.wrapper{
display:block;
background-color:black;
padding:1em;
width:23em;
}
<td>
<div class="wrapper">
  <img src="..." class="img"/>
  <img src="..." class="img"/>
  <div class="text">
    hello world! Lorem ipsum lorem ipsum lorem ipsum loren ipsum
  </div>
</div>
</td>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜