根据窗口大小动态调整div大小 [英] Dynamically resize div based on window size
本文介绍了根据窗口大小动态调整div大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图针对不同的分辨率优化我的网站。在网站的中心,我有一个DIV当前有固定的大小。我试图使其大小(和内容)根据浏览器窗口的大小更改。我怎么做?
这是我的网站,如果你想看看它的代码:
http:// www。 briefeditions.com
I'm trying to optimise my website for different resolutions. In the center of the website I have a DIV that currently has a fixed size. I'm trying to make its size (and contents) change according to the size of the browser window. How do I do that? This is my website if you want to take a look at its code: http://www.briefeditions.com
推荐答案
如果调整页面大小,div将在页面加载时调整大小。
If you resize the page the div will resize with it and on load of the page.
$(window).on('load resize', function(){
$('#div').width($(this).width());
});
这篇关于根据窗口大小动态调整div大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文