if(window.screen.width > 1024){ document.getElementById("container").style.width="100%";}else{ document.getElementById("container").style.width="1024px";} ===============ps:在javascript中得到当前窗口的高和宽