我在div中有一个文本,并且旁边有一个图像。我希望图像位于句子的末尾,即right=0
。但是图像总是放在句子的末尾。
这是我的代码。
<div id='xi' class='xc'>Text comes here and can be anything and any length<img src='images/QuestionExpandArrow.jpg' id='QuestionExpandArrow'></div>
我想把图片放在句子的最右边。
谢谢
吉恩
最佳答案
将float:right
应用于图像本身(通过单独的样式表not inline style
attribute)。您还需要具有图像come before the sentence in HTML。
<head>
...
<style type="text/css" media="all">
#QuestionExpandArrow { float:right }
</style>
</head><body>
...
<div id='xi' class='xc'>
<img src='images/QuestionExpandArrow.jpg' id='QuestionExpandArrow'>
Text comes here and can be anything and any length
</div>
...
</body>