gpt4 book ai didi

html - Internet Explorer 屏幕中的可链接部分失败

转载 作者:太空宇宙 更新时间:2023-11-04 15:06:50 25 4
gpt4 key购买 nike

我必须将图像在两个轴上居中,然后将可链接区域添加到该图像的左上角区域。这对 webkit 和 ff 非常有用,但 ie 失败了。我的 html 代码是这样的:

<body>
<div class="content">
<img src="images/main_image.jpg" />
<a href="#somelinkhere">Logo</a>
</div>
</body>

我的 CSS 代码是这样的:

body, html {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
background-color: #000;
overflow: hidden;
}
div.content {
position: relative;
width: 1001px;
height: 626px;
top: 50%;
margin: 0 auto;
padding: 0;
}
div.content img {
margin: 0;
padding: 0;
display: block;
position: relative;
top: -50%;
}
div.content a {
width: 14%;
height: 9%;
display: inline-block;
position: absolute;
top: -42%;
left: 7%;
text-decoration: none;
margin: 0;
padding: 0;
text-indent: -9999px;
}

这对 ie 不起作用,因为我使用了一个标签,该标签显示为相应定位的内联 block 。我们的 friend ie 根本不在屏幕上显示可链接的部分,因为文本缩进。有人可以帮忙吗?谢谢。这demo我认为会帮助你更多。

最佳答案

看看this demo (或仅结果 here )

HTML 没有改变。我假设图像与内容 div 具有相同的高度/宽度

CSS:

body, html {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
background-color: #000;
overflow: hidden;
}
div.content {
position: relative;
padding: 0;
border:solid 1px blue;
width: 1001px;
height: 626px;
/*below will center div on screen */
top: 50%;
margin: -313px auto 0;

}
div.content img {
margin: 0;
padding: 0;
display: block;
border:solid 1px white;
/*top:-50% removed. Assuming that image has the same height/width as content div*/
}
div.content a {
width: 14%;
height: 9%;
position: absolute;
/* top: -something changed. Remember that absolutely positioned div is always positioned from closest parent relative div*/
top: 10%;
left: 7%;
text-decoration: none;
margin: 0;
padding: 0;
text-indent: -9999px;
border:solid 1px green;
}

关于html - Internet Explorer 屏幕中的可链接部分失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15808771/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com