简体   繁体   English

如何使用HTML / CSS在图像下对齐文本?

[英]How to align text under image using HTML/CSS?

I am trying to align two links under an image as text, the HTML I got works perfect in Chrome and Firefox, however not in IE where 90% of our internal users are. 我正在尝试将图像下的两个链接调整为文本,我得到的HTML在Chrome和Firefox中完美运行,但是在IE中却无法使用,我们90%的内部用户都是HTML。

here is the code.. 这是代码。

    <div style="float: right;"><img src="sites/default/files/recog.png" width="419" height="465" style="border: 6px double #7a9a01;" /><br />
    <p style="text-align: right;"><a href="webform/world-of-thanks">Click to Nominate Online!</a></p>
    <p style="text-align: right;"><a href="hr/files/world-thanks-nomination-form/attachment/newest">Print your nomination form here.</a></p>
    </div>
    <h2>"A World of Thanks!" program</h2>
    <p>The “World of Thanks!” program is a collection of...</p>

In Chrome the above HTML shows the text and content on the left, and the image will show up on the right, with the link text underneath the image to the right. 在Chrome中,上面的HTML在左侧显示文本和内容,在右侧显示图片,并在右侧显示链接文本。

In IE, the links show up first on the left, then the text, the image shows on the right as it should.. but somehow in IE the links are not going under the image instead they are going left of it. 在IE中,链接首先显示在左侧,然后是文本,图像在右侧显示。.但是在IE中,链接不是在图像下方,而是在图像左侧。

Any idea? 任何想法? what am I doing wrong? 我究竟做错了什么?

wrong in IE.. https://oppy.com/it/ie_broken.png 在IE中出错。.https ://oppy.com/it/ie_broken.png
correct in Chrome.. https://oppy.com/it/correct_chrome_only.png 在Chrome中正确。.https ://oppy.com/it/correct_chrome_only.png

a tags are naturally inline-block trying setting your a to display: block; a标签是自然inline-block努力你设置adisplay: block; Same with image tags. 与图像标签相同。 target the image in your css and add display: block; 在您的CSS中定位图片并添加display: block; to that as well 对此

I dont have IE but try this: 我没有IE,但可以尝试以下方法:

JSFIDDLE JSFIDDLE

我没有要测试的IE,但请尝试为div设置一个固定的宽度。

<div style="float: right; width: 431px;">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM