How to use CSS to control the content display separately on PC or mobile terminal

Today, there is a netizen who hopes we can provide some help. This student’s website hopes to add an advertising code to the theme, so that it can be displayed on the mobile end, but not on the PC. It is said that it has taken two hours to find the code on the Internet, but it has not solved the problem. At the beginning, I also thought of using JS code to judge the user’s client and then display them separately. I felt that it was too troublesome. Why not use CSS to control it directly?

For example, if the display is lower than a certain size, we will judge whether it is the mobile terminal, and then let it be displayed. If it is larger than this size, we will judge whether it is the computer terminal. Anyway, he wants the mobile terminal to display it, so he doesn’t need to use complex JS code to judge.

First, display only on the mobile terminal

< div class = "onlywap" >ads displayed on mobile terminals < & div >

.onlywap{display: inline;}
@media (min-width: 950px){.onlywap{ display:none; }}

Second, display only on the computer

< div class = "onlymobile" >ads displayed on the computer end < & div >

.onlymobile{display: none;}
@media (min-width: 950px){.nonlymobile{ display:inline; } }

Anyway, this netizen test can be used.

Related Article
Two methods of using CSS style to intercept the length of the title do not need to use functions

For example, when we make the website template, or choose to download to a good default, maybe due to the Read more

Method to solve the disorder of Chinese content in MySQL database submitted by PHP

Whether it is ASP or PHP programming language, or even other web languages, the basic application is nothing more than Read more

Two regular expression verification methods for PHP user registered mailbox

Generally, when we register or log in to an account on the web, we need to verify not only whether Read more

Three common methods of PHP connecting MySQL database

For PHP entry-level users, we only need to master the basic database write, read, edit, delete and other basic operations. Read more

Leave a Reply

Your email address will not be published. Required fields are marked *

To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-spam image