我編程博客網站,我的妹妹,但我進入我解決不了的問題..如何製作適合屏幕的3等分方格?
我想使她的網站看起來如下:
的職位應該是裏面的方格,和一行3格。但我無法做到這一點。我希望通過利潤擴大並適合屏幕。 (如在以下網站:https://www.chloefromthewoods.com/)
我有以下代碼:
<div id="mainDiv">
<div id="posts">
<div id="post1" class="post">
<div class="postDiv" style="background-image: url(img1.JPG)">
Post...
</div>
</div>
<div id="post2" class="post">
<div class="postDiv" style="background-image: url(img2.JPG)">
Post...
</div>
</div>
<div id="post3" class="post">
<div class="postDiv" style="background-image: url(img3.JPG)">
Post...
</div>
</div>
</div>
</div>
CSS:
#mainDiv
{
max-width: 100%;
width: auto;
min-width: 800px;
min-height: 100px;
height: auto;
margin: 0 auto 300px auto;
overflow: hidden;
}
#posts
{
width: auto;
height: auto;
min-height: 100px;
background: #ffffff;
}
.post
{
/* Make it square and fit the screen */
width: 33%;
height: 33%;
display: inline-block;
float: left;
}
.postDiv
{
width: 100%;
height: 100%;
background-position: center center;
background-size: cover;
}
的jsfiddle:https://jsfiddle.net/9qs34mgw/1/
它使3完美貼合的div,但寬度不同的寬度值,而不是平方http://i.imgur.com/h1ZlEMU.jpg,順便說一句我用JSFIDDLE –