WordPress.org

Forums

[resolved] Create an "if mobile/table then echo" php for website. (4 posts)

  1. kmurrayfrgraphics
    Member
    Posted 1 year ago #

    There is a specific page on my website that when a person is viewing it through a phone or tablet I want it to say:

    "Click for more information"

    This is because the way my responsive java works when you hover over and object on the computer it pops up information, but on the mobile and tablet site you need to "click" on it to show the information.

    I figured it would be a php solution as an "if screen resolution = x then echo "Click for more information"

    I am not sure if I am in the right direction or if there would probably be a java solution.

    If anyone could help that would be awesome.

  2. LasseMT
    Member
    Posted 1 year ago #

    You should use css media queries for this.

    You should create a button that is only displayed on tablets and phones. Look at the css below. Add the class ".hidden-desktop" to the button, and it will only show on tablets and phones. Then you shuould use javascript to show the content when this button is clicked.

    .hidden-desktop    { display: none !important; }
    // Phones only
    @media (max-width: 767px) {
        .hidden-desktop    { display: inherit !important; }
    }
    // Tablets & small desktops only
    @media (min-width: 768px) and (max-width: 979px) {
        .hidden-desktop    { display: inherit !important; }
    }
  3. kmurrayfrgraphics
    Member
    Posted 1 year ago #

    could I do this with a div?

  4. kmurrayfrgraphics
    Member
    Posted 1 year ago #

    I can, thank you very much, great solution!

Topic Closed

This topic has been closed to new replies.

About this Topic