CSS Margin负数,不移动父容器 [英] CSS Margin Negative without Moving Parent Container

查看:106
本文介绍了CSS Margin负数,不移动父容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试进入该页面所在的区域( http://musicaladvocacy.org/)说首页"(灰色渐变中的白色容器")向上移动〜60像素,但是正如您所看到的那样,它也可以使父容器向上移动.我只希望白色盒子向上移动而不是整个移动.因此它应如下所示: http://musicaladvocacy.org/index-margin.jpg

I am trying to get on this page (http://musicaladvocacy.org/) the area where it says "Home" (The White Container in the grey gradient) to go ~60 px up, but as you can see it does that as well as moves the parent container up. I just want the white box to move up NOT the whole thing. So it should look like this: http://musicaladvocacy.org/index-margin.jpg

感谢任何想法!

推荐答案

您可以在需要向上移动的元素上应用position:relative; top:-60px;.

You can apply position:relative; top:-60px; on the element you need to shift up.

#el {
   position:relative;
   top:-60px;
   z-index: 5;
}

这篇关于CSS Margin负数,不移动父容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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