css - 启用 CSS 后图像不显示

标签 css

我只是想把这张图片放在页面中间。这是我非常简单的代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Viva La Nation</title>
    <style>
        #centered {
            margin-left: -148px;
            position: absolute;
            top: -285px;
            left: 50%;
            width: 570px;
            height: 296px;
        }

        body {
            background-image:url('seamless.png');
        }
    </style>
    <meta charset="UTF-8">
    <meta http-equiv="refresh"    
content="10;url=http://www.vivalanation.com/forums">

<link rel="icon" type="image/ico" href="/forums/favicon.ico">
</head>
<body onLoad="setTimeout('delayer()', 10000)">
  <div id="centered">
    <a href="http://www.vivalanation.com/forums/forum.php">
     <img src="images/logo_nin.png" style="border:0px"  />
    </a>        
  </div>    
</body>
</html>

如果我删除 CSS 代码,图像就会显示出来。我按照这个 icnonic 页面将图像置于中心位置:http://www.wpdfd.com/editorial/thebox/deadcentre4.html ,但由于某种原因它不会显示。而且我知道它肯定是 CSS,我只是不知道我哪里出错了。图片的总规范为 570x296。

哦,我刚找到它,它位于屏幕顶部,文本底部几乎看不见。

最佳答案

将边距设置为“自动”,并根据图像的大小以百分比设置顶部。

关于css - 启用 CSS 后图像不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19606318/

相关文章:

javascript - 我在 html 中的图像在 iphone 上重叠导航栏但在其他设备上不重叠

jquery - 使用 jquery 将动画添加到 bootstrap Tooltip

php - Qcodo元素的开关位置

html - 如何使表格标题可见?

jquery - 使用 Jquery Supersized 覆盖 div

html - 如何不将样式应用于表格元素

html - 使用数据 URI 的 Base64 编码 OpenType 字体

javascript - 滑动 div 导致网页超出我的页脚

css - 在旋转的 Div 内换行文本

html - 加载时网站淡出