覆盖div添加边距 [英] cover div adding a margin

查看:120
本文介绍了覆盖div添加边距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 #cover div 与以下css

  #cover {
background-color:#FFFFFF;
height:100%;
opacity:0.4;
position:fixed;
width:100%;
z-index:9000;
}

我想要覆盖整个>

>



但是当我向下滚动时,我看到了





这是因为 margin 左边。



我试图添加 margin:-8 -8 8 8; 没有成功。为什么???如何解决这个问题?



DEMO小提琴。 a>

您可以设置位置。只需添加:

  top:0; 
left:0;

因为你没有发布完整的标记,我只能假设你的身体有一个边缘或填充导致您看到的移动。




i have a #cover div with the following css

#cover {
    background-color: #FFFFFF;
    height: 100%;
    opacity: 0.4;
    position: fixed;
    width: 100%;
    z-index: 9000;
}

i want it to cover the entire (viewed) page like so

however when i scroll down i see this

thats because a margin of 8 is added to the top and the left.

i tried adding margin:-8 -8 8 8; with no success. why??? and how can i fix this?

DEMO fiddle.

解决方案

you fogot to set a position. just add:

top: 0;
left: 0;

since you havn't posted you complete markup, i can only assume your body has a margin or padding causing the shift you're seeing.

这篇关于覆盖div添加边距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆