网站要根据PC端和移动端的访问做不同的响应渲染,该怎么识别pc和移动端是并作相应的跳转呢?视图文件是不是也有分两个?
伊谢尔伦2017-04-17 13:36:08
You have two ways to differentiate between PC and mobile access:
A page, automatic size
mainly uses media queries
to cooperate with the grid system to achieve different display effects under different screen sizes. The responsibility for judgment lies with the front-end page.
One content, two sets of pages
You can completely write two different pages for PC and mobile display respectively. The responsibility for determining the client type falls on the backend, which can be done by detecting the request User-Agent
field in, different browsers have different values.
大家讲道理2017-04-17 13:36:08
If you want to differentiate between PC and mobile, what is the screen width?
PHP中文网2017-04-17 13:36:08
Let me tell you, the responsive layout is just talking about it. There are a few really big websites that are purely responsive, all of which are designed by pcweb.
Unless you have a completely flat design and don’t use any picture materials, then it is possible. Using responsive layout
It really does a lot of things. For example, if you have a mouse operation on a PC and a mouse wheel, you have to change it to sliding on mobile devices
Mobile phones also need to distinguish between horizontal and vertical screens. This is media. It’s about inquiry
Another thing I don’t understand is, why does it need to be rendered in the background? Instead of detecting UA directly in the initial script, if it is a mobile phone, jump directly to the wap side
伊谢尔伦2017-04-17 13:36:08
First of all, let me state some personal opinions
It is not recommended to share one solution for PC and mobile terminals. It is recommended to use two sets of structures to reduce the use of redundant code.
Answer to the poster's question:
If it is based on node, it can be implemented using a template engine. The current premise is to obtain the user's User agent and screen width when you access the page for strict validation.
The template corresponding to the platform is given when outputting the template.