Click here to Skip to main content
15,895,192 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey guys,

so I got part of it working, however when I hover over the image, it brings the image out, however the caption has space on both sides of it.

XML
<article>
     <div class="imageHolder">
        <img src="http://www.corelangs.com/css/box/img/caption4.jpg" alt="" />
           <div class="caption">
               <br>Caption goes here
           </div>
     </div>
</article>


My CSS:

CSS
.imageHolder {
            position: relative;
            width: 285px;
        }

        .imageHolder .caption {
            position: absolute;
            width: 283px;
            height: 50px;
            bottom: 0px;

            color: #ffffff;
            background: green;
            text-align:center;
            font-weight:bold;
            opacity:0.7;
        }

        .imageHolder img {
            transition: all .2s ease-in-out;
        }

        .imageHolder img:hover {
            transform: scale(1.1);
        }


The fiddle: http://jsfiddle.net/noz7v8cw/[^]

any ideas what it is that I'm doing wrong?
Posted
Comments
Sergey Alexandrovich Kryukov 18-Jan-15 18:03pm    
It looks like you are almost there, would need just a bit of debugging. However, I would not do such design at all. Not clear why all that bothering. You scale image just a bit. What's the point? Also, this semi-transparent green band for the caption looks really ugly. Why doing all that?
—SA

XML
try this

css

.imageHolder {
            position: relative;
            width: 285px;
        }

        .imageHolder .caption {
            position: absolute;
            width: 283px;
            height: 50px;
            bottom: 4px;

            color: #ffffff;
            background: green;
            text-align:center;
            font-weight:bold;
            opacity:0.7;
        }

        #test div {
            transition: all .2s ease-in-out;
        }

        #test div:hover {
            transform: scale(1.1);
        }

HTML

<article>
    <div id="test">
                                        <div class="imageHolder">
                                            <img src="http://www.corelangs.com/css/box/img/caption4.jpg" alt="" />
            <b class="caption"><br>Caption goes here</b>
                                            </div>
        </div>
        </article>
 
Share this answer
 
Sorry for not looking to fix this bug; I'm almost sure you are very close and could successfully complete this piece of work.

Instead, I would like to suggest: do something more useful, improve your design instead. So far, it means that like "I can do it" type of decoration. Of course you can. By why? First of all, this semi-transparent green band for the caption, the point of your concerns, is a bad idea itself. You just don't allow the user to enjoy nice picture. It spoils the presentation, it shows label without proper symmetry and reasonable proportion. Even if it looks not too bad on this very picture, it will look uglier on others. Then, why do you scale up your picture at all. You scale it just a bit. Many site visitors won't even hover over it. Why bothering? Hundreds or thousands of Web "designer" already do this cheap trick; so, do you really hope to impress anyone? The real virtual of a Web developer is clarity and simplicity, rare these days. To really stand out, keep it much simple but more functional. Suggest the options to show an image on full screen, in original resolution, and whatever operations you want.

And — keep your picture caption, guess where? Outside of the picture!

My best wishes,
—SA
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900