0

How do I activate certain CSS lines depending on if a user is logged in or not?

Here's how it looks: login mask

I'm currently building a login mask for a client of ours and here's essentially what I want to do:

if_user_is_logged_in -> container-height: 30px; else container-height: 160px;

Here's what I got: the code because it's easier to read this way

In case anyone is unable to tell, I had help with the first bits of code as well.

So to sum up again:

if user is logged in -> style:"height:30px;" default is 160px.

I really appreciate the help I got from this community so far :)

3

You can use the logged-in class added by body_class to target your CSS rules.

.container { height: 160px }
body.logged-in .container { height: 30px }
  • 1
    So essentially.. I don't even need PHP, I can just add that into the CSS-File of my theme? – theHubi Aug 12 '15 at 14:26
  • 1
    Awesome! Thanks a lot! I knew of the "logged-in" class but apparently I had a brainfart or something. I appreciate the help! – theHubi Aug 12 '15 at 14:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.