html - 页眉不适用于背景图片

标签 html css image web background

我要重新设计我的网站。在 Body CSS 中,我放置了 background-img。然后,我当然为页眉制作了一个 div class="header"

但是当我发布页面时,页眉不显示。我试过几种浏览器和计算机,但什么也看不到。 然后我在手机上试了一下。在手机上它只能在纵向模式下工作,但不能像在桌面上那样在横向模式下工作。在 iPad 上也是如此。

<!doctype html>
    <html lang="en">
        <head>

    <meta charset="utf-8" />
            <title>Home</title>

            <style type="text/css">
                * {padding: 0; margin: 0;}
                body {background: url(http://farm4.staticflickr.com/3785/9603354598_e7a32b5505_o.jpg) no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover;  -o-background-size: cover; background-size: cover; }
                .header {margin-top: 50px; width: 1400px; position:fixed; height: 70px; background-color:rgba(0,0,0,0.5); /* Fallback for web browsers that doesn't support RGBa */ background: rgb(0, 0, 0) transparent;  /* RGBa with 0.6 opacity */  background: rgba(0, 0, 0, 0.6);  /* For IE 5.5 - 7*/ filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000); /* For IE 8*/ -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000)"; color: white; margin-top: 80%; }
                .titles {opacity: 1;  font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;  font-weight: 300;}
                .title {margin-top: 10px; margin-left: 2%; font-size: 40px; font-family: Futura, "Trebuchet MS", Arial, sans-serif;}
                .subtitle {margin-top: -12px; margin-left: 130px; font-size: 10px; font-family: Futura, "Trebuchet MS", Arial, sans-serif;}
            </style>

  </head>

        <body>
     <div class="header">
        <div class="titles" align="left">
          <div class="title">TITLE</div>
          <div class="subtitle">subtitle</div>
        </div>
     </div>

        </body>
    </html>

知道问题出在哪里吗? 在我的代码应用程序中,页面运行完美。

谢谢!

最佳答案

请删除标题 CSS 中的边距顶部。我在下面的示例中对此进行了评论。请忽略我的红色边框,只是用作“调试”。

查看我的 DEMO

.header {
    margin-top: 50px; 
    width: 1400px; 
    position:fixed; 
    height: 70px; 
    background-color:rgba(0,0,0,0.5); 
    /* Fallback for web browsers that doesn't support RGBa */ 
    background: rgb(0, 0, 0) transparent;  
    /* RGBa with 0.6 opacity */  
    background: rgba(0, 0, 0, 0.6);  
    /* For IE 5.5 - 7*/ 
    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000); 
    /* For IE 8*/
    -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000, endColorstr=#99000000)"; 
    color: white;
/* margin-top: 80%;*/ 
}

关于html - 页眉不适用于背景图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21955579/

相关文章:

jquery - 根据窗口大小动态更改类名

javascript - 如何遍历图像数组并将它们呈现在 React 的组件中?

html - 根据 TextMate 中的属性修改 HTML 语法

html - Bootstrap 与 form-inline in row 右对齐

javascript - 如何在 html/Javascript 中实现列表容器?

jquery - 宽度自动不更新与挖空文本绑定(bind)

jquery - 如何隐藏单选框中的复选框?

javascript - 使用 Greasemonkey 将文本更改为图像(在静态站点上)?

android - 如何在我的 android gridview 中显示来自互联网的图像并显示完整图像?

jquery - 使用 jquery 获取跨度内的文本