Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 16
Like Tree3Likes

Thread: Hover to reveal text help!

  1. #1
    Senior Member
    Join Date
    Jan 2011
    Posts
    148
    Member #
    26229
    Liked
    1 times

    Hover to reveal text help!

    Hi there,

    I have been having difficulty getting the hover function work on a site I am currently building.
    As it stands I have an image, which on overlay I would like to display text that I can format through CSS.

    Currently my code is quite simple, which I think should do it...

    CSS
    p1{font-size:1.3em;text-align:left;color:#ffffff;font-family: 'geosanslightregular';margin:100px 20px 0px 20px;padding:0;}
    div.containerdiv{position:relative}
    div.texts{position:absolute; top:0; left:0; width:100%; display:none; z-index:10}
    div.texts:hover{display:block}

    HTML
    <div class="grid_8">
    <a href="cncpt.html">
    <div class="containerdiv">
    <img src="images/cncpt.jpg" alt="background">
    <div class="texts">
    <p1>LAUNCH OF E-COMMERCE MENSWEAR STORE, STOCKING EVERYONE FROM BALMAIN AND GIVENCHY TO ADIDAS X OPENING CEREMONY, YMC, NIKE AND BEYOND. BREAK HOSTED THE LAUNCH EVENT AND INTRODUCED 200+ KEY MEDIA, BRAND AND INDUSTRY CONTACTS TO THE STORE. WE CONTINUE TO OPERATE THE PRESS OFFICE FOR CNCPT AND HAVE PICKED UP FANS EVERYWHERE FROM GQ DAILY AND METRO, TO KEY ONLINE INFLUENCERS.</p1>
    </div>
    </div>
    </a>
    </div>
    <!-- end .grid_8 -->

    As it stands nothing happens on hover and I've gone through it a few times, even looking at a JQuery solution, which stopped me being able to style the text!
    If anyone is able to take a look and see where I am going wrong it would be hugely appreciated!

    Thanks,
    John

  2.  

  3. #2
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    Well, for one thing, <p1> doesn't exist...

    For another thing, the image is outside the container you're hovering, and the container is set to display:none. You can't hover something that isn't there. Try like this:
    HTML Code:
    <div class="hoverThing">
      <img src="whatever" />
      <p>Some text and what-not</p>
    </div>
    Code:
    .hoverThing{
      position:relative;
    }
    .hoverThing p{
      display:none;
      position:absolute;
      top:0;
      left:0;
    }
    .hoverThing:hover p{
      display:block;
    }
    That should get the functionality going for you. From there, just style it up.
    Last edited by Ronald Roe; Aug 16th, 2013 at 04:50 AM.
    TheGAME1264 likes this.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  4. #3
    Senior Member
    Join Date
    Jan 2011
    Posts
    148
    Member #
    26229
    Liked
    1 times
    Will try this out, thanks very much

  5. #4
    Senior Member
    Join Date
    Jan 2011
    Posts
    148
    Member #
    26229
    Liked
    1 times
    sorry one more question, how do I lose the image on hover and just show a white background?

  6. #5
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    .hoverThing:hover img {display: none;}
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  7. #6
    Senior Member Andrew Yurlov's Avatar
    Join Date
    Apr 2011
    Location
    Portland, OR
    Posts
    1,306
    Member #
    27566
    Liked
    181 times
    First you need to set a class on the image. Then just use css to do what you want. Should be something like this

    <img src="" class="background">

    img.background{
    display: block;
    }

    .hoverThing:hover img.background{
    display: none;
    }
    Artificial intelligence is nothing compared to natural stupidity -Someone

    Design is a funny word. Some people think design means how it looks.
    But of course, if you dig deeper, itís really how it works.
    -Steve Jobs



  8. #7
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    You don't even have to remove the image. Just give the <p> a solid background.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  9. #8
    Senior Member
    Join Date
    Jan 2011
    Posts
    148
    Member #
    26229
    Liked
    1 times
    Thanks very mcuh for this both, am having an issue... have tried both and had the same result, stopped the text showing up at all.

  10. #9
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    Is this like what you put in there?
    Code:
    .hoverThing p{background:white;}
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  11. #10
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    You don't have to set a class on the image in this case...it's the only one. You can use the tag to adjust it. .hoverThing img and .hoverThing img.background will do the exact same thing in this particular instance.

    As far as what's going on now...JONNYB, upload it so we can see it, please.
    Ronald Roe likes this.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:04 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com