How to disable link to phone number when on Desktop?

后端 未结 20 948
清酒与你
清酒与你 2021-02-03 23:47

How can I add a phone number to a website that is clickable but hides the link when I\'m browsing on a website that doesn\'t support touch.

I could use Modernizr to set

20条回答
  •  盖世英雄少女心
    2021-02-04 00:10

    I found the best way. I get that this is old, but I found a very easy way of doing this.

    Using this code below

    888-555-5555
    
    //This is the logic you will add to the media query
    .not-active {
       pointer-events: none;
       cursor: default;
    }
    

    In your CSS make use of media queries. So make a media query for all desktops

    @media only screen and (min-width: 64em) {
        /* add the code */
        .not-active {
           pointer-events: none;
           cursor: default;
        }
    }
    

    Now all desktop sized pages wont be able to click on it.

提交回复
热议问题