CSS Problem on div and link

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dafodil
    Contributor
    • Jul 2007
    • 389

    CSS Problem on div and link

    I have a problem on divs and links. I have a particular <div> before a link. I want that div to change its background image when the link is active. Is that possible on css?

    I'm not really into designing web apps cause I'm really into programming. Please help me with this one. Thanks.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    I'm not completely sure, but I think that you can't style ancestor elements with CSS.

    regards

    Comment

    • dafodil
      Contributor
      • Jul 2007
      • 389

      #3
      Sorry for not making it clear. I am making a menu button.
      I created one of its button using
      [CODE="html"]<div style="backgrou nd-image: url('../a.gif')"> </div> <a href="" style="backgrou nd-image: url('../a.gif')">link</a> <div style="backgrou nd-image: url('../a.gif')"> </div> [/CODE]

      As you can see I used the first and last divs not to position the image but to hold images. so I can have a round end for my menus.

      I used a.active on css to change the background of my link whenever clicked or visited. My problem now is that I can't change the left and right divs background image on click of the link. Any ideas? Thanks

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        you don't have left and right divs. unless you changed the display or float properties, your divs are above and below.

        what exactly is a "round end"?

        maybe a transparent (transparency containing) gif will do?

        or maybe that
        Code:
        <a href="..." style="background..."><img src="left_side.gif">link_text<img src="right_side.gif"></a>

        Comment

        • dafodil
          Contributor
          • Jul 2007
          • 389

          #5
          I am using a gif for the background. I can't load all the images for my menu buttos because my links have different sizes. It will cost much memory space. any suggestions?

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            images are not loaded twice, and they are cached on the browser (except when the expires header or the browser cache is set to 0). further, you can stretch an image simply by changing its height/width attributes.

            Comment

            • dafodil
              Contributor
              • Jul 2007
              • 389

              #7
              I tried the code you had given but I can't use it because I got an image that has link in it. and the center top of my background doesen't have a link. Still sir I'm curious if it is possible to change my div after activating a link?

              Comment

              • Dormilich
                Recognized Expert Expert
                • Aug 2008
                • 8694

                #8
                I'd need a link to the page to give better advice (currently I don't have a clear picture what the page looks like)

                Comment

                • dafodil
                  Contributor
                  • Jul 2007
                  • 389

                  #9
                  How can I upload images here?

                  Comment

                  • Dormilich
                    Recognized Expert Expert
                    • Aug 2008
                    • 8694

                    #10
                    post a reply, then push the "edit" button, there you have (further down, under options) a button "manage attachments".

                    alternatively link to an image on a server using the [img] tags

                    Comment

                    • dafodil
                      Contributor
                      • Jul 2007
                      • 389

                      #11
                      Heres the attached image of my menu.

                      Youll notice the menu buttons above the blue bar.
                      I used the same html code stated on my previous post. One button contains 3 elements. a left div, a link and a right div. If I click the link I can change the background picture of the link but I also want to change the divs in it.
                      Attached Files

                      Comment

                      • Dormilich
                        Recognized Expert Expert
                        • Aug 2008
                        • 8694

                        #12
                        something like that?
                        Image-driven, visually compelling user interfaces. Text-based, semantic markup. Now you can have both! Douglas Bowman’s sliding doors method of CSS design offers sophisticated graphics that s…

                        In Sliding Doors of CSS Part I, Douglas Bowman introduced a new technique for creating visually stunning interface elements with simple, text-based, semantic markup. In Part II, he pushes the techn…

                        Comment

                        • drhowarddrfine
                          Recognized Expert Expert
                          • Sep 2006
                          • 7434

                          #13
                          You can't do it the way you have it. If you can place the images without using the divs then wrap the anchors around the images. Then you can use CSS selectors to change the background.

                          Comment

                          • dafodil
                            Contributor
                            • Jul 2007
                            • 389

                            #14
                            Dormilich, thats what I needed. Thanks a lot.

                            drhowarddrfine, Your right. Thanks for the advice.

                            Comment

                            Working...