我正致力於構建我們公司主網站的移動友好網站。它的設計方式是約2倍視網膜。我打算做的是將主要內容設置爲最大寬度640px,寬度設置爲100%。我有一個適合做這個的特定背景圖片。但隨着div的寬度變小,我需要調整高度。有任何想法嗎?保持div高度與長寬比相關
這裏的CSS:
*{margin:0;padding:0}h1,h2,h3,h4,h5,p,li,a,cite{font-size:14px;font-weight:normal}button,img{border:0}body{font-family:Arial, sans-serif;}
body {
margin:0;
background-color:#fff;
}
.top, .body {
max-width:640px;
width:100%;
margin:0 auto;
}
.top {
background: white url(images/top.jpg) no-repeat;
background-size:auto;
overflow:hidden;
height:124px;
max-height:124px;
}
.top ul {
list-style:none;
height:100%;
}
.top ul li {
height:100%;
float:left;
display:block;
}
你可能想看看這個博客文章:(看起來他是基於你的答案:) http://inspectelement.com/tutorials/a-responsive-css-background-image-technique/ – Danield
可能: )。我相信我遇到了某處,併爲我的目的做了一些調整。 – agmcleod
有趣的想法。你是否有任何瀏覽器兼容性問題? –