标题不显示在主页以外的页面上

时间:2016-11-19 21:25:01

标签: html css

所以,我的网站主页上有一个标题。它完全对齐,一切都很好,但是,当我去任何其他页面时,标题消失了。我已经尝试了有无位置:固定,但它仍然消失。它应该存在的空间仍然存在,但我认为标题本身是不可见的。

我有另一个div停留在页面之间,所以我不知道可能是什么问题。我比较了两个CSS代码,但唯一的区别是位置,颜色,大小等。

这是标题的CSS:

.bar {
    margin-top:-810px;
    margin-left:300px;
    width:1075px;
    height:60px;
    background-color:#b0b0b0;
    font-size:16px;
    color:#e7e55a;
    text-align:center;
    line-height:60px;
    font-family: 'Coming Soon', cursive;
    position:fixed;
    z-index:1;
}

这是其他div的CSS保留在原地:

#tra img {
    width: 225px;
    height: auto;
    margin-top:60px;
    margin-right:0px;
    transform:rotate(-55deg);
    z-index:1;
}

由于第二个div是一个图像,我想这可能就是为什么它保持原位,但我真的不是最好的编码,所以任何帮助都会受到赞赏。

另外,我已经尝试过没有z-index的代码,但它仍然无效。

1 个答案:

答案 0 :(得分:3)

如果使用固定位置,请使用顶部,左侧,底部和右侧来定位元素。不要使用保证金。



.bar {
    top: 0;
    left: 300px;
  
    width:1075px;
    height:60px;
    background-color:#b0b0b0;
    font-size:16px;
    color:#e7e55a;
    text-align:center;
    line-height:60px;
    font-family: 'Coming Soon', cursive;
    position:fixed;
    z-index:1;
}

<div class="bar"></div>
&#13;
&#13;
&#13;