Forums

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

Home Forums CSS :before Pseudo-Elements When Dealing with Prices

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #45596
    realph
    Participant

    I’m building a site where my client is going to be regularly inputting prices. At the moment all they need to do is type in the price, and using the :before element I chuck a pound sign (£) in front of the number. This looks a little something like this:

    .price:before {
    content: ‘£’;
    }
    The problem I’m running into is some prices are prefixed with the word “from”, which as you might have guessed look a little like this:

    £from 15

    Is there a way to use the :before element before the first number using pure CSS?

    Any help would be appreciated. Thanks in advance!

    #139424
    Paulie_D
    Member

    Basically…no.

    You could do

    .price:after {
    content: ‘pounds’;
    }

    #139428
    Kitty Giraudel
    Participant

    If I may, the currency is kind of an important part of the price thus it probably shouldn’t be inserted with CSS.

    #139430
    Paulie_D
    Member

    >If I may, the currency is kind of an important part of the price thus it probably shouldn’t be inserted with CSS.

    Indeed, the symbol is content and should be part of the HTML…it’s not a style applied to the price.

    #139481
    realph
    Participant

    @Paulie_D @HugoGiraudel You guys are right, I’ll make them punch in the pound sign. Thanks!

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