hide parts of site on mobile devces

前端 未结 2 1723
鱼传尺愫
鱼传尺愫 2021-01-29 07:55

I have the following snippet of code and I want only show the headers on mobile unless the header is clicked. Tried a few things but nothing works.

2条回答
  •  一整个雨季
    2021-01-29 08:35

    Bootstrap has classes you can use to show or hide content at certain breakpoints: hidden-xs, hidden-sm, etc. You'd probably want hidden-xs.

    You can then hav ea click handler on your h3 elements that toggles that class on the h5. This will be a no-op on larger screens, but on smaller ones it will show/hide the element.

    In this example I use jQuery for the JavaScript part (using event delegation), but that's a detail; the point is the concepts and the responsive classes provided by Bootstrap:

    $(".container-fluid").on("click", "h3", function() {
      $(this).nextAll("h5").first().toggleClass("hidden-xs");
    });
    
    

    Executive hire

    Coach Hire

    Limo Hire

    Minibus Hire

    Services

    AREAS COVERED

提交回复
热议问题