Jump to content

[FYI] Change content when in mobile view using Psuedo-element "::before"


Recommended Posts

This custom solution will allow you to change the content of an HTML element depending on your device.

You just need to create an HTML BLOCK or use a HEADER and FOOTER and disable the HTML editor.

Take note that this is not the actual use of a Psuedo-Element ("::before"). This is just an experiment that I tried on my App.

Put the following script:

<style>
p#test::before {
  content: "This message is for the Desktop viewer"; /*You can change this part to show your own message for Desktop view*/
}

@media (max-width: 640px) {
p#test::before {
  content: "This message is for the Mobile viewer"; /*You can change this part to show your own message for Mobile view*/
}
}
}
</style>

<p id="test"></p> /*This will be the container of your messages*/
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...