Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Create an "if"rule when URL contains /en/ using CSS

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #281025
    Billy_MX
    Participant

    Hi guys,
    I’ve been learning some CSS on my own over the past couple of months when I started building websites for my clients (I’m more a marketer/paid traffic guy).
    I’m currently building a Real Estate website and I’m looking to crate an “if” rule when the URLs contains the “/en/” for the website English version… I don’t know if it’s possible.

    Here’s the thing: I used some CSS to add the word “Desde” before the price on my WordPress Theme as you can see in this property URL:
    https://playareef-realestate.com/propiedades/33-Departamentos-Preventa-Entrega-Agosto-2019-Bah%C3%ADa-de-Pr%C3%ADncipe-USD165-000/

    I added the following CSS lines:
    .price_box:before {
    content: ‘DESDE ‘;
    }

    Is it possible to add a CSS condition rule like this: if URL contains /en/ → then change the word “Desde” for “Starting from”.
    Thanks!!

    #281026
    Beverleyh
    Participant

    It isn’t possible with CSS alone; you would need PHP or JavaScript doing some logic like;
    1. Get/identify URL
    2. Search URL for “/en/”
    3. If found, add “en” class to html or body element

    THEN, with this class present, you can utilise a CSS override selector;

    .en .price_box:before {
    content: ‘Starting From ‘;
    }

    #281033
    Billy_MX
    Participant

    Ohh ok I see Beverleyh. I really appreciate your help 😉
    I’ll have to hire a freelancer as I’m not familiar with JS or PHP.
    Thanks again!

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘CSS’ is closed to new topics and replies.