简体   繁体   English

如何使此标题完全对齐?

[英]How can I make this header perfectly aligned?

I am using the following header design, which should take over the top part of the page 100% horizontally but in some browsers on the right hand side it wouldn't cover it. 我使用以下标题设计,它应该水平100%地接管页面的顶部,但在右侧的某些浏览器中它不会覆盖它。

How can i fix this? 我怎样才能解决这个问题?

HTML: HTML:

 <header id="loop">
 <img src="/images/logo.png" height="50px" />
 </header>

CSS: CSS:

 background-color: #990000;
 height: 85px;
 margin-left: -8px;
 margin-top: -8px;
 position: relative;
 width: 101.3%;

It's a bit hard to tell with no solid example. 没有可靠的例子,有点难以分辨。

Make sure that the body/header margin values: 确保正文/标题边距值:

body { margin: 0; }

Also, remove the width value you put in your css and reset your margins. 另外,删除放在css中的宽度值并重置边距。 Your CSS should be: 你的CSS应该是:

background-color: #990000;
height: 85px;
position: relative;
width: 100%;

The problem is your negative margin-left of 8px and the width of 101.3%. 问题是你的负余量 - 左边8px和宽度101.3%。 That fills the full width only when the screen width is more than 615px. 仅当屏幕宽度超过615px时,才会填满整个宽度。

The best option is to get rid og the margin and use a width of 100%. 最好的选择是摆脱边际并使用100%的宽度。

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

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