十分感谢,初步的想法实现了,但是只能赋值给一个id,而缩略图有很多。
为了最终效果,我对代码做了调整,目前的情况是这样,能不能赋高度值给公用的class,这样所有的图片就都获取高度了:
HTML:
<div id="thumbnailbox">
<a href="post_1.html" title="缩略图1"> <div class="thumbnail" id="1"></div> </a> </div>
<a href="post_2.html" title="缩略图2"><div class="thumbnail" id="2"></div></a>
...
</div>
一行一共四个div,自动撑满浏览器,css部分:
#humbnailbox {
width: 100%;
margin: 0 auto;
clear: both;
}
.thumbnail {
width: 25%;
float: left;
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
}
#1 {
background-image: url(../images/1.jpg);
}
#2 {
background-image: url(../images/2.jpg);
}
......
感谢了,我追加50分给
你这样的写的话 不先赋值给thumbnail统一的高度的话恐怕页面会显得参差不齐而不是你想的4块模块平均撑开页面,还有你是把图片写进div你当背景,那就不需要js来处理这个问题。