如何在窗口大小调整时自动调整字体和图像(完整网站)的大小?
如何在窗口大小调整时自动调整字体和图像(完整网站)的大小? 人们会有不同的屏幕分辨率。
CSS? jquery? html %(在 Chrome 中效果不佳)
我需要制作幻灯片(演示文稿,幻灯片是用 ckeditor 制作的)
How do i automatically resize Fonts and Images (complete Website) on window-resize?
The people will have different screen-res.
css? jquery? html % (didnt work well in chrome)
I need to make a slideshow (presentaion, slides are made with ckeditor)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这里我创建了一个 jQuery 脚本来调整字体大小和图像宽度。这会在页面加载和基于浏览器宽度百分比调整窗口大小时触发。
演示:http://jsfiddle.net/Crndp/4/
您可以通过数学变得更复杂根据您的需要调整图像大小,但这是基本思想。
Here I created a jQuery script to adjust the font-size and img width. This triggers on page load and on window resize based on a percentage of the width of the browser.
Demo: http://jsfiddle.net/Crndp/4/
You can get more complex with the math on the image resizing based on your needs however this is the basic idea.
您可以将几乎任何事件附加到以下内容:
但如果您想制作更具适应性的内容,则必须评估
html 的
元素,从中您可以得出合理的字体大小。width
xheight
实际上没有办法进一步概括它,您必须根据具体情况为要调整大小的元素编写一个函数。
You can attach almost any event to something like:
But if you wanted to make something that was more adaptable you'd have to evaluate the
width
xheight
ofhtml
element, from that you can derive a reasonable size for the fonts.There is really no way to generalize it any further, you'd have to write a function on a case by case basis for the elements you'd want to resize.
我想您会发现这篇关于响应式网页设计的文章非常有帮助:
http://www.smashingmagazine.com/2011/01/12/guidelines-for-responsive-web-design/
它介绍了如何利用灵活的图像和如何实现媒体查询(以及其他有用的东西)。
原文由A List Apart撰写(smashing 在这里那里添加了一些东西):http://www.alistapart.com/articles/responsive-web-design/
这是响应式演示的完成的 HTML /em>: http://www.alistapart .com/d/responsive-web-design/ex/ex-site-FINAL.html
I think you will find this article on Responsive Web Design to be very helpful:
http://www.smashingmagazine.com/2011/01/12/guidelines-for-responsive-web-design/
It goes through how to utilise flexible images and how to implement Media Queries (along with other useful things).
The original article was written by A List Apart (smashing have added a few things here and there): http://www.alistapart.com/articles/responsive-web-design/
Here is the finished HTML of the responsive demo: http://www.alistapart.com/d/responsive-web-design/ex/ex-site-FINAL.html