How does js control the display style of a control by determining whether the access request comes from a mobile device?
漂亮男人
漂亮男人 2017-05-19 10:25:08
0
2
422

Hello everyone.
I am a newbie in front-end development. I recently learned to make a very ugly website, which is mainly used to download Weibo videos, Miaopai videos, etc.

The function I want to achieve is: on all pages of this website for downloading Weibo videos and Miaopai videos, if accessed from PC, the menu bar on the left will be displayed, which is col-md-3. For Android, Access from mobile terminals such as iPhone does not display the col-md-3 menu bar on the left, but only displays the col-md-9 part on the right.

I have basically implemented this function now, using the window.onload function. By default, col-md-9 is set to display:none. In the onload function, if it is determined to be a request from the PC side, col-md -3 is displayed, which causes the page to always be rendered first when accessed on the PC, and then the screen flashes before the col-md-3 menu appears.

I would like to ask all seniors, is there any way to achieve this function of mine under one URL (without distinguishing between mobile and PC) without the current screen flickering result?
I have tried all the methods on the Internet, but basically they did not solve my problem.
thank you all!

漂亮男人
漂亮男人

reply all(2)
阿神

With bootstrap, you don’t have to write these manually

https://jsfiddle.net/straybug...

Written like this, if you feel like adjusting the size, press xs -> sm -> md to adjust it upward

Ty80

Several methods

  1. Write this part of onload to the top of the page.

  2. Make this judgment on the server

  3. Use media queries to write styles based on the screen resolution.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!