如何定义最大1200像素的网站?

时间:2018-02-06 15:08:39

标签: html css

当有人说html网站最大为1200像素时,这是什么意思? 如何在html或css中定义它以使网站的宽度不超过1200像素?

4 个答案:

答案 0 :(得分:1)

在您的css脚本上添加此内容

<html>
<head>
    <style type="text/css">
        body {
             max-width: 1200px;
        }
    </style>
</head>
<body>
</body>
<html>

答案 1 :(得分:1)

只需将主容器设置为:

.container{
max-width: 1200px;
width:100%;
margin:0 auto;
}

max-width将设置最大宽度为1200px,width: 100%将设置.container内的内容以填充其容器的最大空间(在本例中为1200px),{{1对于那些大于1200px的窗口,将margin: 0 auto置于窗口中。

答案 2 :(得分:0)

在你的身体css上添加

my-internal-proxy-2     | 2018-02-06T15:03:15.500664406Z time="2018-02-06T15:03:15Z" level=debug msg="vulcand/oxy/forward: begin ServeHttp on request" Request="{"Method":"GET","URL":{"Scheme":"http","Opaque":"","User":null,"Host":":80","Path":"","RawPath":"","ForceQuery":false,"RawQuery":"","Fragment":""},"Proto":"HTTP/1.1","ProtoMajor":1,"ProtoMinor":1,"Header":{"Accept":["*/*"],"Accept-Encoding":["gzip"],"User-Agent":["curl/7.47.0"],"X-Forwarded-For":["public.ip.xx, 10.4.2.116, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1....

最初可能会在google上搜索,只是一个建议。

答案 3 :(得分:0)

我认为这个术语指的是网站正文的实际内容。

以下代码中的关键项是max-width:1200px;

这将修复整个网站内容的宽度,使其永远不会超过指定的大小。

div.container {
  width: 100%;
  max-width:1200px;
  border: 1px solid gray;
}

header,
footer {
  padding: 1em;
  color: white;
  background-color: black;
  clear: left;
  text-align: center;
}

nav {
  float: left;
  max-width: 160px;
  margin: 0;
  padding: 1em;
}

nav ul {
  list-style-type: none;
  padding: 0;
}

nav ul a {
  text-decoration: none;
}

article {
  margin-left: 170px;
  border-left: 1px solid gray;
  padding: 1em;
  overflow: hidden;
}
<div class="container">

  <header>
    <h1>City Gallery</h1>
  </header>

  <nav>
    <ul>
      <li><a href="#">London</a></li>
      <li><a href="#">Paris</a></li>
      <li><a href="#">Tokyo</a></li>
    </ul>
  </nav>

  <article>
    <h1>London</h1>
    <p>London is the capital city of England. It is the most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants.</p>
    <p>Standing on the River Thames, London has been a major settlement for two millennia, its history going back to its founding by the Romans, who named it Londinium.</p>
  </article>

  <footer>Copyright &copy; W3Schools.com</footer>

</div>