Answer the question
In order to leave comments, you need to log in
How to set the width of the DIV block calculated from the width of the browser window?
I have the following:
CSS (in a separate file):
.vneshniy_blok{
width: 100%;
height: 100%;
background: yellow;
}
.vnutrenniy_blok{
width: auto;
height: auto;
background: blue;
display: flex;
justify-content: center;
flex-wrap: wrap;
}
.blok{
width: 150px;
height: 100px;
background: white;
float: left;
}
<div class="vneshniy_blok">
<div class="vnutrenniy_blok">
<div class="blok">1</div>
<div class="blok">2</div>
<div class="blok">3</div>
......
<div class="blok">100</div>
</div>
</div>
Answer the question
In order to leave comments, you need to log in
I love, of course, logical (and not so) puzzles, but even the condition is somehow strange.
function ost(el) {
var ok = el%150;
if(ok==0){
return el;
}else {
return (el - ok + 10);
}
}
var vse_divi = document.getElementsByClassName('blok');
var nadow = ost(window.innerWidth);
for (var i = 0; i < vse_divi.length; i++) {
vse_divi[i].setAttribute("style" , "width:" + nadow + "px");
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question