如何让网页自适应手机屏幕分辨率_html/css_WEB-ITnose
我做的网页感觉在不同屏幕分辨率下显示效果不同,现在又什么好的办法解决这个问题没,能让网页自适应屏幕分辨率
并且布局保持不变 不管多大屏幕显示的是整个页面的放大或缩小之后的布局
回复讨论(解决方案)
width:100%;
$(window).bind('resize load', function(){$("body").css("zoom", $(window).width() / 640);$("body").css("display" , "block");});
试试呢~~
用link标签
...
...
<meta name="viewport" content="width=320px, user-scalable=no, initial-scale=1, maximum-scale=1">
<meta name="viewport" content="width=320px, user-scalable=no, initial-scale=1, maximum-scale=1">
又学习了,不过手机同时兼容大显示器分辨率还是不行吧。毕竟尺寸在哪里呢
用ui框架吧,或者去看看响应式设计方面的书.
ui框架:bootcss
这个可以参考参考 http://www.ruanyifeng.com/blog/2012/05/responsive_web_design.html
$(window).bind('resize load', function(){$("body").css("zoom", $(window).width() / 640);$("body").css("display" , "block");});
非常感谢2楼啊
这段在做应用中嵌入网页,被嵌入的网页总被缩放,非常烦恼。
让安卓工程师加上此句后:webSettings.setSupportZoom(false); 仍旧还是被缩放。
( 加上这句 target-densitydpi=device-dpi 可强制显示真实分辨率大小)
页面所有字号大小,都按照某一宽度
比如设计图页面宽度640的,然后所有不同分辨率的手机,都按640px缩放。
再加上2楼的这段代码。就解决了大屏手机高分辨率下,字体过小的问题。而且切图时也不用考虑多种分辨率的不同css,统统按只支持640px的做就足矣!
刚开始写css的时候就应该注意到,不可以写死的宽高,要用百分比及最大最小值的设定
加上这句
width - viewport的宽度 height - viewport的高度
initial-scale - 初始的缩放比例
minimum-scale - 允许用户缩放到的最小比例
maximum-scale - 允许用户缩放到的最大比例
user-scalable - 用户是否可以手动缩放
推荐一个网站给你,我自己也是做移动端Web的。http://razorflow.com/这个是专门用于针对移动端开发的产品
还有个方法就是用base.css文件,不过用base.css文件的话不能做到在不同客户端下显示不同排版。
$(window).bind('resize load', function(){$("body").css("zoom", $(window).width() / 640);$("body").css("display" , "block");});
非常感谢2楼啊
这段在做应用中嵌入网页,被嵌入的网页总被缩放,非常烦恼。
让安卓工程师加上此句后:webSettings.setSupportZoom(false); 仍旧还是被缩放。
( 加上这句 target-densitydpi=device-dpi 可强制显示真实分辨率大小)
页面所有字号大小,都按照某一宽度
比如设计图页面宽度640的,然后所有不同分辨率的手机,都按640px缩放。
再加上2楼的这段代码。就解决了大屏手机高分辨率下,字体过小的问题。而且切图时也不用考虑多种分辨率的不同css,统统按只支持640px的做就足矣!
楼主,我最近也在做手机端开发,这两句话直接放在js和head里就可以用了吗,我的怎么没用啊
去看看jqm(jqueryMobile),或许能改变你的思路!
$(window).bind('resize load', function(){$("body").css("zoom", $(window).width() / 640);$("body").css("display" , "block");});
非常感谢2楼啊
这段在做应用中嵌入网页,被嵌入的网页总被缩放,非常烦恼。
让安卓工程师加上此句后:webSettings.setSupportZoom(false); 仍旧还是被缩放。
( 加上这句 target-densitydpi=device-dpi 可强制显示真实分辨率大小)
页面所有字号大小,都按照某一宽度
比如设计图页面宽度640的,然后所有不同分辨率的手机,都按640px缩放。
再加上2楼的这段代码。就解决了大屏手机高分辨率下,字体过小的问题。而且切图时也不用考虑多种分辨率的不同css,统统按只支持640px的做就足矣!
可是这种方法有个问题呢,火狐和Opera不支持zoom,其他手机浏览器对zoom支持度也待确定
$(window).bind('resize load', function(){$("body").css("zoom", $(window).width() / 640);$("body").css("display" , "block");});
试试呢~~
非常感谢~~~

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.
