How to target the current page in CSS

Hi there,

Here is what I am trying to do:

  1. I have some custom code that determines the results of some calculations on a page. I use the Classic Raw Content element to show the results on a page. In the desktop view, the display is part of the page. But in the mobile view, I want to show the calculation results in a static overlay at the bottom of the page. In other words, I want my code to behave like the “content area off canvas” element.
  2. Most of my code is working but I am having some trouble keep the static overlay during all scrolling states. I think I may be doing something wrong.
  3. So here is my question: what is the best technique to show some static overlay that always sticks to the bottom of the page?

Thanks.

Hi Misha,

Thank you for reaching out to us.

  • You can target a page by it’s Page ID in CSS, to find out page / post ID you can checkout the following article https://theme.co/apex/forum/t/setup-how-to-locate-post-ids/59

  • You can use the media queries to style your element in smaller screens e.g you can make use of the following code to stick your overlay at the bottom of the page:

@media screen and (max-width: 767px) {
    .your-overlay-class {
        position: absolute;
        bottom: 0;
    }
}

You can adjust the bottom value in the above code as per your need. If you would like to learn CSS, I am sharing few resources that you take a look to get started with CSS and an interesting tool that you can use to speed up the development process.

I recommend you to watch following video that will help you to get started with CSS.

https://www.youtube.com/watch?v=MFR4WXiLzpc

Sometimes it can get a bit difficult to find out the right selector to be able to write the required CSS codes. A handy tool that can help you in this is Google Chrome dev tools. I am sharing the resource that you can refer to get started with dev tools.

https://developers.google.com/web/tools/chrome-devtools/css/

https://developers.google.com/web/tools/chrome-devtools/

https://www.youtube.com/watch?v=tP_kXBJWPhQ&t=200s

Hope this helps!

Thanks @Nabeel. We will give this a try.

You are most welcome. :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.