Changing HTML from CSS media query

后端 未结 4 1421
不知归路
不知归路 2021-02-04 11:47

I have a situation in which I want to change an HREF in an unordered list in HTML when a CSS media query is true. Specifically I want to change an HREF from calendar.html to ca

4条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-04 12:45

    I think it will easy if you create both link in html

    
    
    

    and then use the css to hide the one that you don't want to show

    #schedule_link_mobile{
        display: none;
    }
    #schedule_link_pc{
        display: inline-block;
    }
    @media only screen 
        and (max-device-width : 667px) 
        and (orientation : portrait) 
        and (-webkit-min-device-pixel-ratio : 2)
    {
        #schedule_link_mobile{
            display: inline-block;
        }
    
        #schedule_link_pc{
            display: none;
        }
    }
    

提交回复
热议问题