2016-09-05 77 views
-3

即使使用窗口上的CTRL +滚动鼠标按钮调整大小,我也想将网站的所有内容放在全屏幕背景中。修复了以居中内容为背景的背景

网站为例:http://www.benzinga.com/网站

三季度都是这样的呢。 (Facebook,微博,StackOverflow的......)我的意思

例子:

(Click for the Image)

如果你按住CTRL键,用鼠标上的滚动按钮,你会看到的背景标题保持全屏显示,但内容保持居中。

只有使用HTML和CSS才能做到这一点吗?

你能告诉我如何?

谢谢!

回答

0

您可以在第一行添加:

body{ 
margin: 0 auto; 
padding-left:240px; 
padding-right: 240px; 
} 

填充您可以根据需要设定的值。 my demo

0

这是我的意思。我自己找到了解决方案。谢谢大家。

<body> 

    <header> 
     <div class="pageSize" > 
      <p class="left">header</p> 
      <p class="right">header</p> 
     </div> 
    </header> 

</body> 

 body { 
      margin: 0; 
      padding: 0; 
     } 

     p { 
      font-size: 30px; 
     } 

     header { 
      background: #5AFFE5; 
      margin: 0; 
      height: 100px; 
     } 



     .pageSize { 
      width: 960px; 
      margin: 0 auto; 
     } 

     .left{ 
      float: left; 
      line-height: 0em; 
     } 

     .right{ 
      float: right; 
      line-height: 0em; 
     } 

     div:before, div:after { 
      content: ""; 
      display: table; 
     } 

     div:after { 
      clear: both; 
     } 

    </style>