search
HomeWeb Front-endHTML TutorialDevelop a website that is compatible with PC access and mobile phone access. _html/css_WEB-ITnose

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
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
What is the difference between an HTML tag and an HTML attribute?What is the difference between an HTML tag and an HTML attribute?May 14, 2025 am 12:01 AM

HTMLtagsdefinethestructureofawebpage,whileattributesaddfunctionalityanddetails.1)Tagslike,,andoutlinethecontent'splacement.2)Attributessuchassrc,class,andstyleenhancetagsbyspecifyingimagesources,styling,andmore,improvingfunctionalityandappearance.

The Future of HTML: Evolution and TrendsThe Future of HTML: Evolution and TrendsMay 13, 2025 am 12:01 AM

The future of HTML will develop in a more semantic, functional and modular direction. 1) Semanticization will make the tag describe the content more clearly, improving SEO and barrier-free access. 2) Functionalization will introduce new elements and attributes to meet user needs. 3) Modularity will support component development and improve code reusability.

Why are HTML attributes important for web development?Why are HTML attributes important for web development?May 12, 2025 am 12:01 AM

HTMLattributesarecrucialinwebdevelopmentforcontrollingbehavior,appearance,andfunctionality.Theyenhanceinteractivity,accessibility,andSEO.Forexample,thesrcattributeintagsimpactsSEO,whileonclickintagsaddsinteractivity.Touseattributeseffectively:1)Usese

What is the purpose of the alt attribute? Why is it important?What is the purpose of the alt attribute? Why is it important?May 11, 2025 am 12:01 AM

The alt attribute is an important part of the tag in HTML and is used to provide alternative text for images. 1. When the image cannot be loaded, the text in the alt attribute will be displayed to improve the user experience. 2. Screen readers use the alt attribute to help visually impaired users understand the content of the picture. 3. Search engines index text in the alt attribute to improve the SEO ranking of web pages.

HTML, CSS, and JavaScript: Examples and Practical ApplicationsHTML, CSS, and JavaScript: Examples and Practical ApplicationsMay 09, 2025 am 12:01 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML is used to build web page structure; 2. CSS is used to beautify the appearance of web pages; 3. JavaScript is used to achieve dynamic interaction. Through tags, styles and scripts, these three together build the core functions of modern web pages.

How do you set the lang attribute on the  tag? Why is this important?How do you set the lang attribute on the tag? Why is this important?May 08, 2025 am 12:03 AM

Setting the lang attributes of a tag is a key step in optimizing web accessibility and SEO. 1) Set the lang attribute in the tag, such as. 2) In multilingual content, set lang attributes for different language parts, such as. 3) Use language codes that comply with ISO639-1 standards, such as "en", "fr", "zh", etc. Correctly setting the lang attribute can improve the accessibility of web pages and search engine rankings.

What is the purpose of HTML attributes?What is the purpose of HTML attributes?May 07, 2025 am 12:01 AM

HTMLattributesareessentialforenhancingwebelements'functionalityandappearance.Theyaddinformationtodefinebehavior,appearance,andinteraction,makingwebsitesinteractive,responsive,andvisuallyappealing.Attributeslikesrc,href,class,type,anddisabledtransform

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.

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 Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),