I'm trying to do it this way:
var width = window.innerWidth;
if (width < 600) {
document.getElementByClassName('2').setAttribute("style","clear: right;");
}
My html here. I already use @media How i can set style only for second div by media queries?
@media all and (min-width: 241px) {
#blog-recent-block {
width: 50%;
float: left;
}
}
@media all and (min-width: 600px) {
#blog-recent-block {
width: 25%;
float: left;
}
}
<div id="blog-recent">
<div id="blog-recent-block" class="1"></div>
<div id="blog-recent-block" class="2"></div>
<div id="blog-recent-block" class="3"></div>
<div id="blog-recent-block" class="4"></div>
</div>