如何在this link上创建一个块?
这是我到目前为止所尝试的:
window.onload = function(){
var height = 0;
var width = 0;
var count_blocks = 0;
width = window.innerWidth;
var h_right_block = document.getElementById('right_block').offsetHeight;
var h_i_right_block = document.getElementById('i_right_block').offsetHeight;
h_i_right_block += 20;
if(h_i_right_block > h_right_block){
var w_Scroll = getScrollBarWidth();
count_blocks = (width - 270 - w_Scroll) / 270;
}else{
count_blocks = (width - 270) / 270;
}
count_blocks = Math.floor(count_blocks);
var diff_width_block = 250 / count_blocks;
diff_width_block = Math.round(diff_width_block);
diff_width_block = 250 - diff_width_block;
//diff_width_block = diff_width_block + "px";
$( '.box' ).css( 'width', diff_width_block );
};
答案 0 :(得分:1)
你可以尝试这个:jsfiddle url:http://jsfiddle.net/Khumesh/qsbtfhx4/
CSS: 。部分 { 明确:两者; 填充:0px; 保证金:0px; }
.col {
display: block;
float: left;
margin-right: 2px;
margin-bottom: 2px;
border: 1px solid #000;
}
.col:first-child {
margin-left: 0;
}
.group:before,
.group:after {
content: "";
display: table;
}
.group:after {
clear: both;
}
.group {
zoom: 1; /* For IE 6/7 */
}
.span_3_of_3 {
width: 100%;
}
.span_2_of_3 {
width: 66.1%;
}
.span_1_of_3 {
width: 32.2%;
}
@media only screen and (max-width: 480px) {
.col {
margin: 1% 0 1% 0%;
}
.span_3_of_3, .span_2_of_3, .span_1_of_3 {
width: 100%;
}
}
HTML:
<div class="section group">
<div class="col span_1_of_3">
This is column 1
</div>
<div class="col span_1_of_3">
This is column 2
</div>
<div class="col span_1_of_3">
This is column 3
</div>
<div class="col span_1_of_3">
This is column 4
</div>
<div class="col span_1_of_3">
This is column 5
</div>
<div class="col span_1_of_3">
This is column 6
</div>
<div class="col span_1_of_3">
This is column 7
</div>
<div class="col span_1_of_3">
This is column 8
</div>
<div class="col span_1_of_3">
This is column 9
</div>
</div>
答案 1 :(得分:-2)