search
HomeWeb Front-endHTML Tutorial如何让网页自适应手机屏幕分辨率_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">
可以试试。

又学习了,不过手机同时兼容大显示器分辨率还是不行吧。毕竟尺寸在哪里呢

用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");});	


试试呢~~




非常感谢~~~
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How do you create a list in HTML?How do you create a list in HTML?May 06, 2025 am 12:01 AM

TocreatealistinHTML,useforunorderedlistsandfororderedlists:1)Forunorderedlists,wrapitemsinanduseforeachitem,renderingasabulletedlist.2)Fororderedlists,useandfornumberedlists,customizablewiththetypeattributefordifferentnumberingstyles.

HTML in Action: Examples of Website StructureHTML in Action: Examples of Website StructureMay 05, 2025 am 12:03 AM

HTML is used to build websites with clear structure. 1) Use tags such as, and define the website structure. 2) Examples show the structure of blogs and e-commerce websites. 3) Avoid common mistakes such as incorrect label nesting. 4) Optimize performance by reducing HTTP requests and using semantic tags.

How do you insert an image into an HTML page?How do you insert an image into an HTML page?May 04, 2025 am 12:02 AM

ToinsertanimageintoanHTMLpage,usethetagwithsrcandaltattributes.1)UsealttextforaccessibilityandSEO.2)Implementsrcsetforresponsiveimages.3)Applylazyloadingwithloading="lazy"tooptimizeperformance.4)OptimizeimagesusingtoolslikeImageOptimtoreduc

HTML's Purpose: Enabling Web Browsers to Display ContentHTML's Purpose: Enabling Web Browsers to Display ContentMay 03, 2025 am 12:03 AM

The core purpose of HTML is to enable the browser to understand and display web content. 1. HTML defines the web page structure and content through tags, such as, to, etc. 2. HTML5 enhances multimedia support and introduces and tags. 3.HTML provides form elements to support user interaction. 4. Optimizing HTML code can improve web page performance, such as reducing HTTP requests and compressing HTML.

Why are HTML tags important for web development?Why are HTML tags important for web development?May 02, 2025 am 12:03 AM

HTMLtagsareessentialforwebdevelopmentastheystructureandenhancewebpages.1)Theydefinelayout,semantics,andinteractivity.2)SemantictagsimproveaccessibilityandSEO.3)Properuseoftagscanoptimizeperformanceandensurecross-browsercompatibility.

Explain the importance of using consistent coding style for HTML tags and attributes.Explain the importance of using consistent coding style for HTML tags and attributes.May 01, 2025 am 12:01 AM

A consistent HTML encoding style is important because it improves the readability, maintainability and efficiency of the code. 1) Use lowercase tags and attributes, 2) Keep consistent indentation, 3) Select and stick to single or double quotes, 4) Avoid mixing different styles in projects, 5) Use automation tools such as Prettier or ESLint to ensure consistency in styles.

How to implement multi-project carousel in Bootstrap 4?How to implement multi-project carousel in Bootstrap 4?Apr 30, 2025 pm 03:24 PM

Solution to implement multi-project carousel in Bootstrap4 Implementing multi-project carousel in Bootstrap4 is not an easy task. Although Bootstrap...

How does deepseek official website achieve the effect of penetrating mouse scroll event?How does deepseek official website achieve the effect of penetrating mouse scroll event?Apr 30, 2025 pm 03:21 PM

How to achieve the effect of mouse scrolling event penetration? When we browse the web, we often encounter some special interaction designs. For example, on deepseek official website, �...

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.