For example: suppose I designed a website only for mobile version and if I try to switch in desktop. how can I give a kind of alert saying that- "To be viewed only in mobile" or something????
            Asked
            
        
        
            Active
            
        
            Viewed 46 times
        
    -2
            
            
        - 
                    1Does this answer your question? [Detecting a mobile browser](https://stackoverflow.com/questions/11381673/detecting-a-mobile-browser) – UkFLSUI May 18 '20 at 04:39
2 Answers
2
            
            
        You can use CSS media queries for that:
@media only screen and (max-width: 768px) {
    /*something*/
}
Every device with a width of 0px to 768px will will get the styles in that rule set.
Alternatively, you can use JS if you want to show a JS alert. (alert('hey'))
Here is and MDN doc of the topic: https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries
 
    
    
        Roy
        
- 1,612
- 2
- 12
- 38
0
            
            
        You can do something like this:
<div class="content">
<!-- your content -->
</div>
<div class="fallback-content">
<!-- your fallback content -->
</div>
<style>
.content{
  //your style
}
.fallback-content{
   display: none;
}
@media(min-width:600px){
 .content{
   display: none;
 }
 .fallback-content{
   display: block;
 }
}
</style>
 
    
    
        Vikas Katal
        
- 39
- 3
