Table of Contents
Reply to the discussion (solution)
Home Web Front-end HTML Tutorial Develop a website that is compatible with PC access and mobile phone access. _html/css_WEB-ITnose

Develop a website that is compatible with PC access and mobile phone access. _html/css_WEB-ITnose

Jun 24, 2016 pm 12:16 PM

The company has developed a portal website. There is no problem when accessing it on a PC. However, when accessing it with the browsing ball that comes with a mobile phone, there are problems with the layout and the layout is very poor.
My idea is whether it is possible to determine whether the user is accessing the website from a mobile phone or using a PC. If so, we can do two sets of things. The PC accesses the portal website with rich layout, and the mobile phone accesses the streamlined version. website.
If not, I hope the experts can give me a solution.


Reply to the discussion (solution)

There must be two sets of pages accessed by PC and mobile phone. The pages on PC have a lot of content, but the pages on mobile phones generally need to be streamlined. How to call and judge should be a matter for programmers, I don’t know, haha ​​

Search for HTTP_ACCEPT

You can consider making a portal and choose whether to enter the PC or mobile page.

Today’s browsers on smartphones are basically not much different from actual PC browsers (except for speed). As long as your page meets W3C standards, it should be displayed the same.
If you must distinguish between browsers, you can look at userAgent. Each browser has a unique userAgent. userAgent can be obtained on the client via
window.navigator.userAgent
. On the server side, it depends on what technology you use. Generally, it will be mentioned in the documentation.

Today’s browsers on smartphones are basically not much different from actual PC browsers (except for speed). As long as your page meets W3C standards, it should be displayed the same .
If you must distinguish between browsers, you can look at userAgent. Each browser has a unique userAgent. userAgent can be obtained on the client via
window.navigator.userAgent
. On the server side, it depends on what technology you use. Generally, it will be mentioned in the documentation.

I don’t want to distinguish which browser is accessed now, I want to distinguish whether it is accessed using a mobile phone or a computer. UserAgent can only distinguish which browser is used.

This is very easy, just make two sets of CSS style sheets with different layouts, and then like the following:

The principle of this is not to judge on your side, but to use the functions of the browser itself on your computer or mobile phone to achieve it. Because they themselves will check the CSS that best meets their requirements. If you do not specify the CSS suitable for mobile phones, it can only use the solution for computers, so the effect is not ideal.

There is no need to do anything like this yourself. Learn to take advantage. Of course, for non-smartphones, if you use WML or the like, then your website must be converted. But you seem to exclude them, which is correct and unnecessary.

It can be judged by using js. For example: !/((iPhone|iPad|iPod)/i.test(navigator.userAgent) This only judges whether it is an Apple handheld device. You can also judge. Others

Pay attention!

This is very easy, just make two sets of CSS style sheets with different layouts, and then do as follows:

...
I also plan to make two sets.
The current problem is to achieve automatic jump. For example, my project is deployed under www.myWebSite.com. There are three html in the project directory, namely index.html, computer.html, and telphone.html. The user enters by default Under index.html, it is determined whether the user enters from a mobile phone or a computer. If the user enters from a mobile phone, it will enter telphone.html. If the computer enters, it will enter computer.html

servlet

servlet
Can you be more detailed?

Quoting the reply from theforever on the 7th floor:
This is very easy. Just make two sets of CSS style sheets with different layouts, and then like the following:

I also plan to make two sets of things.
The problem now is to realize automatic jump.
The two sets I mentioned are not the two sets you think.
The two sets you want are from HTML to CSS and even to the whole image.
I mean two sets, just CSS, the page is still one page, so there is no need to jump at all. Depending on the device, different CSS solutions will naturally be called. As long as you arrange the page layout and write the CSS well, one page will produce two completely different display effects suitable for different devices.

As for the method for the program to detect the device and then jump, it can be implemented in both the background and the foreground.
But in that case, two sets of things are time-consuming and labor-intensive to make, and more troublesome to maintain. If one part changes, the other must be modified simultaneously.
My method is to consider allowing you to achieve it at the lowest cost now and in the future.

As for the method for the program to detect the device and then jump, it can be implemented in both the background and the foreground.
But in that case, two sets of things are time-consuming and labor-intensive to make, and more troublesome to maintain. If one part changes, the other must be modified simultaneously.
My method is to consider allowing you to achieve it at the lowest cost now and in the future.
The current requirement is that two sets must be made, because the contents of the two accesses are completely different. There are only two modules that can be accessed by mobile phones, "FAQ" and "Software Download", but there are many more contents that can be accessed by computers. . In the end, the discussion decided to make two sets, including pages, css and pictures.
You said above that it is easy to detect device jumps. Can you tell me your method?

Unless the mobile browser and PC browser can obtain differentiated information using JS, it is impossible.

And whether the user surfs the Internet on a mobile phone or a computer, strictly speaking, it is personal privacy.

Pay attention... I don’t know how the industry implements it? For example, wap.sina.com

How to make a mobile website, experts can teach me

I don’t know about the poster’s problem Have you solved it? I also encountered the same problem, that is, the PC and mobile websites are two completely different pages. I just need to distinguish them. I don’t know what to do. The poster is asking if you can help me if you have solved the problem. Please tell me. Thank you.

js determines what is the system platform of the browser used in the navigator object

Statement of this Website
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

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

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Is HTML easy to learn for beginners? Is HTML easy to learn for beginners? Apr 07, 2025 am 12:11 AM

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.

What is the purpose of the <progress> element? What is the purpose of the <progress> element? Mar 21, 2025 pm 12:34 PM

The article discusses the HTML &lt;progress&gt; element, its purpose, styling, and differences from the &lt;meter&gt; element. The main focus is on using &lt;progress&gt; for task completion and &lt;meter&gt; for stati

The Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

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.

What is the purpose of the <datalist> element? What is the purpose of the <datalist> element? Mar 21, 2025 pm 12:33 PM

The article discusses the HTML &lt;datalist&gt; element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

What is the purpose of the <meter> element? What is the purpose of the <meter> element? Mar 21, 2025 pm 12:35 PM

The article discusses the HTML &lt;meter&gt; element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates &lt;meter&gt; from &lt;progress&gt; and ex

What is an example of a starting tag in HTML? What is an example of a starting tag in HTML? Apr 06, 2025 am 12:04 AM

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

Understanding HTML, CSS, and JavaScript: A Beginner's Guide Understanding HTML, CSS, and JavaScript: A Beginner's Guide Apr 12, 2025 am 12:02 AM

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

Gitee Pages static website deployment failed: How to troubleshoot and resolve single file 404 errors? Gitee Pages static website deployment failed: How to troubleshoot and resolve single file 404 errors? Apr 04, 2025 pm 11:54 PM

GiteePages static website deployment failed: 404 error troubleshooting and resolution when using Gitee...

See all articles