我正在按照教程构建针对移动设备的响应式网站。
本教程中sample website的宽度定义为百分比:
(CSS)
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style type="text/css" media="screen, projection">
.section:after,
ul.nav:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
/* http://meyerweb.com/eric/tools/css/reset/ */
/* v1.0 | 20080212 */
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td { margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent; }
body { line-height:1; }
ol,ul { list-style:none; }
blockquote,q { quotes:none; }
blockquote:before,blockquote:after,q:before,q:after { content:'';content:none; }
ins { text-decoration:none; }
del { text-decoration:line-through; }
table { border-collapse:collapse;border-spacing:0; }
body {
background: #E4E4E4 url("site/bg.png");
color: #292929;
color: rgba(0, 0, 0, 0.82);
font: normal 100% Cambria, Georgia, serif;
-moz-text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
-webkit-text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
-webkit-text-size-adjust: none;
}
a {
color: #890101;
text-decoration: none;
-moz-transition: 0.2s color linear;
-webkit-transition: 0.2s color linear;
transition: 0.2s color linear;
}
a:hover {
color: #DF3030;
}
#page {
background: url("site/rag.png") repeat-x;
padding: 2em 0;
}
.inner {
margin: 0 auto;
width: 93.75%; /* 960px / 1024px */
}
img {
max-width: 100%;
}
.amp {
font-family: Baskerville, Garamond, Palatino, "Palatino Linotype", "Hoefler Text", "Times New Roman", serif;
font-style: italic;
font-weight: normal;
}
.mast {
float: left;
width: 31.875%; /* 306px / 960px */
}
h1 {
background: url("site/logo-bg.png") no-repeat 50% 0;
}
h1 a {
padding-top: 117px;
height: 162px;
display: block;
text-align: center;
}
.intro,
.main,
.footer {
float: right;
width: 65.9375%; /* 633px / 960px */
}
.intro {
margin-top: 117px;
}
.intro div {
line-height: 1.4;
}
ul.nav {
border-top: 1px solid #888583;
margin: 2em auto 0;
width: 64.379%;
}
ul.nav a {
background: url("site/ornament.png") no-repeat 0 100%;
font: bold 14px/1.2 "Book Antiqua", "Palatino Linotype", Georgia, serif;
display: block;
text-align: center;
letter-spacing: 0.1em;
padding: 1em 0.5em 3em;
margin-bottom: -1em;
text-transform: uppercase;
}
ul.nav a:hover {
background-position: 50% 100%;
}
li.first a {
border-top: 1px solid #FFF9EF;
padding-top: 1.25em;
}
ul.nav i {
font: normal 10px Baskerville, Garamond, Palatino, "Palatino Linotype", "Hoefler Text", "Times New Roman", serif;
display: block;
letter-spacing: 0.05em;
}
.intro h2 {
font: normal 2em "Hoefler Text", "Baskerville old face", Garamond, "Times New Roman", serif;
text-align: center;
margin-bottom: 0.25em;
}
.main h2 {
background: url("site/ornament.png") no-repeat 0 50%;
font-size: 1.4em;
text-transform: lowercase;
text-align: center;
margin: 0.75em 0 1em;
}
.main h2 b {
background: url("site/bg.png");
font-weight: normal;
padding: 0 1em;
}
.figure {
float: left;
font-size: 10px;
letter-spacing: 0.05em;
line-height: 1.1;
margin: 0 3.317535545023696682% 1.5em 0; /* 21px / 633px */
text-align: center;
text-transform: uppercase;
width: 31.121642969984202211%; /* 197px / 633px */
}
.figure b {
display: block;
font-size: 14px;
font-family: "Book Antiqua", "Palatino Linotype", Georgia, serif;
letter-spacing: 0.1em;
}
.figure img {
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
-webkit-box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
-moz-box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);;
display: block;
margin: 0 auto 1em;
}
li#f-mycroft,
li#f-winter {
margin-right: 0;
}
.footer {
background: url("site/ornament.png") 50% 0 repeat-x;
font-size: 12px;
text-align: center;
padding: 40px 0 20px;
}
.footer p {
margin-bottom: 0.5em;
}
</style>
</head>
我不知道为什么该教程的作者选择1024px作为其基于百分比的布局的基础。
可能是什么原因?
(我有点困惑,因为评论说960px,所以我假设作者希望布局的最大宽度为960px,但在我的浏览器中显示为1148.43px)。
最佳答案
平板电脑的大多数分辨率为"1024px"
。
例如:Ipad-纵向视图。
关于css - 为什么该网站将1024px作为其基于百分比的布局的基础?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7288453/