1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.5 Can't get a conditional statement to work in CSS template

Discussion in 'Troubleshooting and Problems' started by Aivaras, Jan 10, 2016.

  1. Aivaras

    Aivaras Active Member

    I need to set a condition for applying padding to an element. The template in question is "public.css".

    My current CSS code is as follows:

    Code:
        .message.horizontal .messageUserBlock a.username
        {
            margin-left: -24px;
            padding-left: 9px;
        }
    I need "padding-left: 9px;" to apply only when the user chooses to be visible. In order to achieve this I enclosed it in a conditional statement:

    Code:
        .message.horizontal .messageUserBlock a.username
        {
            margin-left: -24px;
            <xen:if is="{$user.visible}">padding-left: 9px;</xen:if>
        }
    Unfortunately, it's not working. Where is my mistake?
     
  2. Mike

    Mike XenForo Developer Staff Member

    You can't use conditionals in CSS. It doesn't have access to user information. You would need to modify the HTML to add a class dynamically to detect what you want and then adjust the CSS to account for that.
     
  3. Aivaras

    Aivaras Active Member

    I see! Which HTML template should I tackle in this particular case?
     
  4. Mike

    Mike XenForo Developer Staff Member

    I believe message_user_info has the area you're looking for.
     
  5. Aivaras

    Aivaras Active Member

    Thanks! I'll give it try.
     

Share This Page