CSS 将内容下推页面

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7750715/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 01:53:19  来源:igfitidea点击:

CSS to push content down page

css

提问by Tim

On a web page I'm working on I have a fixed #top section containing the nav which is causing the content below to partially hide behind it.

在我正在处理的网页上,我有一个固定的 #top 部分,其中包含导航,这导致下面的内容部分隐藏在它后面。

The page is this: http://s361608839.websitehome.co.uk/pt-build/templatebuild/

页面是这样的:http: //s361608839.websitehome.co.uk/pt-build/templatebuild/

I've tried adding margin-top to #slider and margin-bottom to #top to try and push each other apart but none of those have worked.

我试过将 margin-top 添加到 #slider 并将 margin-bottom 添加到 #top 以尝试将彼此分开,但这些都没有奏效。

Any ideas?

有任何想法吗?

采纳答案by Emil

just change

只是改变

div.anythingSlider {
  position: relative;
  padding: 110px 350px 28px 45px;
}

I changed the top padding from 0 to 110px

我将顶部填充从 0 更改为 110px

回答by Kokos

Your #topis fixed, so the margins won't work.

#topfixed,所以边距不起作用。

You have to do two things to fix this problem:

你必须做两件事来解决这个问题:

  1. Give your bodya padding-topor margin-topequal to the height of #top(151px)
  2. Give #topa top:0;so it still sticks to the top of the page.
  1. 给你body一个padding-topmargin-top等于#top(151px)的高度
  2. 给出#top一个top:0;这样它仍然会粘在页面的顶部。

回答by devDeejay

You can use

您可以使用

div.anythingSlider{
    position: relative;
    top: 50%;
    transform: translateY(-50%);
}

top: 50%will shift your content down while translateYwill put it back in place.

top: 50%将您的内容向下移动,同时translateY将其放回原位。

回答by LAW

Use padding-top:150px; on the div with class anythingSlider

使用 padding-top:150px; 在类anythingSlider的div上

回答by oezi

just add top: 0;to #topwrapand margin-top: 100pxto body. (replace 100px with a value you like, 100px is the minimum to see the first heading, but your #topwrapis 151px tall - just try wich looks best)

只需添加top: 0;#topwrapmargin-top: 100pxbody。(将 100px 替换为您喜欢的值,100px 是看到第一个标题的最小值,但您#topwrap的高度为 151px - 尝试看起来最好)