1

I hope someone will be able to help me with this, because it's starting to freak me out.

Have been searching hours to find a way to put image paths in my stylesheet, but have not been able to. The path must not be absolute or "theme dependant". The only way I have been able to fix my issue, is to do add the following within my html file:

<style type="text/css">
    #menu .menu-drop .menu-label {
        background: url(<?php echo get_template_directory_uri()."/admin/images/drop1.png"; ?>) no-repeat right;
    }
    #menu li:hover .menu-drop .menu-label {
        background: url(<?php echo get_template_directory_uri()."/admin/images/drop2.png"; ?>) no-repeat right;
    }
    #menu .menu-sub li:hover {
        background: #2a2a2a url(<?php echo get_template_directory_uri()."/admin/images/select.png"; ?>) no-repeat 10px;
    }
</style>

As you can see, I simply add the background image "manually" in the html file after including the stylesheet in the header.

Any idea how to transfer the above to a stylesheet, or is that not possible?

1
  • 1. Blow no. 1 — The path must not be absolute or "theme dependant" 2. Blow no. 2 — transfer the above [CSS] to a stylesheet — The way it is, you simply CAN'T. Or you will have to frame your question more clearly. You are confused, and so am I, after reading it. :)
    – its_me
    Commented Jul 7, 2012 at 8:22

1 Answer 1

0

Use a relative path in your stylesheet. If the CSS file is in /style.css:

#menu .menu-drop .menu-label {
    background: url(admin/images/drop1.png) no-repeat right;
}
3
  • can't get relative path to work either. Guess I have to insert it manually in the admin.php page instead of my stylesheet :( Commented Jul 7, 2012 at 12:18
  • Explain why you cannot use relative paths.
    – fuxia
    Commented Jul 7, 2012 at 12:29
  • The css file is placed in a CSS folder, this worked though: background: url("../images/drop1.png") no-repeat right; Your solution worked though, thanks ;) Commented Jul 7, 2012 at 18:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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