The MU forums have moved to WordPress.org

link from style sheet (7 posts)

  1. jagalizzi
    Member
    Posted 15 years ago #

    How can I do a link on an image but from a style sheet?

    This is a the code of the style sheet:

    #footer{
    width:100%;
    height:45px;
    background:url(images/barra_blog.gif) no-repeat top left;
    clear:both;

  2. Ovidiu
    Member
    Posted 15 years ago #

    sorry I don't understand. Do you mean you have a background image and you want to be able to assign a link to it so you can click it?

    I guess you can't as thats what separating content from markup means: the markup/design is in the css files and the content is inside the php/html/whatever files

  3. cafespain
    Member
    Posted 15 years ago #

    You have to put the anchor (link) in the php/html

    So you could have something like this in your footer:

    <div id='footer'>
    <a href='myurl' id='footerlink'></a>
    </div>

    And in your CSS:

    #footer{
    position: relative;
    width:100%;
    height:45px;
    background:url(images/barra_blog.gif) no-repeat top left;
    clear:both;
    }
    #footerlink {
    position: absolute;
    border: 0;
    width: 100%;
    top: 0;
    left: 0;
    height: 25px; /* Or whatever height your footer image is */
    }

    That might work

  4. Ovidiu
    Member
    Posted 15 years ago #

    thats cheating ;-) he asked:

    How can I do a link on an image but from a style sheet?

    you are putting the link inside the php :-)

  5. cafespain
    Member
    Posted 15 years ago #

    I know I know, but I'm in a helpful mood at the moment, and they don't come along very often :)

    So, to agree with Ovidiu, you can't :) I've just tried to use the CSS content property, but that doesn't allow markup, so I guess you're stuck...

  6. jagalizzi
    Member
    Posted 15 years ago #

    So, do you mean it's impossible?

    It should be a way to do it...

  7. cafespain
    Member
    Posted 15 years ago #

    Yep, it's pretty much impossible and technically "there shouldn't be a way to do it" because "Cascading style sheets are used to format the layout of Web pages." (http://www.techterms.com/definition/css).

    So the the layout and the functionality is defined by the HTML. Links will have to go into the HTML (or Javascript code), but "how the links look" will go into the CSS.

About this Topic

  • Started 15 years ago by jagalizzi
  • Latest reply from cafespain