Enhancing images with dual captions using CSS hover effects

I have been experimenting with creating an image that, upon hover, displays a caption sliding out from left to right on the top and bottom. I have managed to achieve this effect on two separate images - one displaying the top caption and the other displaying the bottom caption. However, I am struggling to implement both effects on the same image. Additionally, I am trying to make sure that the captions and the image scale properly to fit the container, which has been quite challenging. I also attempted to insert two divs into the top slide caption to get them to scale accordingly, but I couldn't quite figure it out. Here is the current state of my code:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>slide caption thingy</title>
    <link rel="stylesheet" type="text/css" media="screen" href="style.css" />
</head>
<body>
    <div class="wrapper">

        <header>
            <h1 class="main_head">hj</h1>
        </header>

        <hr />

        <div class="container left">
            <img src="images/1.jpg" alt="image" />
            <article class="text css3-3 css3-4">
                <h1><a href="#" class="css3-3 css3-4">space1</a>    </h1>
            </article>
        </div>

        <div class="container right">
            <img src="images/2.jpg" alt="image" />
            <article class="text css3-4">
                <h1><a href="#" class="css3-4">space2</a></h1>
            </article>
        </div>

        <hr />

    </div>

</body>
</html>

CSS

 * {
        margin: 0;
        padding: 0;
    }

    body {
    }

    .wrapper {
        margin: 0 auto;
        width: 960px;
        padding: 30px;
        position: relative;
    }

    .left {
        float: left;
    }

    .right {
        float: right;
    }

    hr {
        border: none;
        width: 100%;
        height: 7px;
        margin: 10px 0 10px 0;
        clear: both;
    }

    a {
        text-shadow: 1px 1px #efefef;
        text-decoration: none;
    }

    b {
        text-shadow: 1px 1px #efefef;
        text-decoration: none;
    }

    header h1.main_head {
        font: 36px/18px Georgia, Arial, sans-serif;
        color: #838383;
        text-shadow: 1px 1px #efefef;
        text-align: center;
        padding: 20px 0 20px 0;
    }


    .container {
        border: 10px solid #fff;
        position: relative;
        overflow: hidden;
        height: 200px;
        -webkit-box-shadow: 0 0 3px #000;
        -moz-box-shadow: 0 0 3px #000;
        box-shadow: 0 0 3px #000;
        -webkit-transition: all .5s ease-out;
        -moz-transition: all .5s ease-out;
        transition: all .5s ease-out;
    }

        .container:hover {
            cursor: pointer;
            -webkit-box-shadow: 0 0 10px #000;
            -moz-box-shadow: 0 0 10px #000;
            box-shadow: 0 0 10px #000;
        }



    .container2 {
        border: 10px solid #fff;
        position: relative;
        overflow: hidden;
        height: 200px;
        -webkit-box-shadow: 0 0 3px #000;
        -moz-box-shadow: 0 0 3px #000;
        box-shadow: 0 0 3px #000;
        -webkit-transition: all .5s ease-out;
        -moz-transition: all .5s ease-out;
        transition: all .5s ease-out;
    }

        .container2:hover {
            cursor: pointer;
            -webkit-box-shadow: 0 0 10px #000;
            -moz-box-shadow: 0 0 10px #000;
            box-shadow: 0 0 10px #000;
        }

    .text {
        background: rgba(0,0,0,0.5);
        color: white;
        font: 14px Georgia,serif;
        height: 80px;
        width: inherit;
        position: absolute;
    }

        .text a {
            color: #fff;
            display: block;
            padding: 15px;
            font-size: 16px;
            font-weight: normal;
            text-shadow: none;
            text-decoration: none;
            width: 400px;
        }



    /* CSS3 Right Effect */
    article.css3-3 {
        right: -400px;
        top: 0;
        -webkit-transition: all .5s ease-out;
        -moz-transition: all .5s ease-out;
        -o-transition: all .5s ease-out;
        transition: all .5s ease-out;
        width: 400px;
    }

    .text a.css3-3 {
        -webkit-transition: all .4s ease-out;
        -moz-transition: all .4s ease-out;
        -o-transition: all .5s ease-out;
        transition: all .4s ease-out;
    }

        .text a.css3-3:hover {
            color: #d0206a;
            text-decoration: none;
        }

    .container:hover article.css3-3 {
        right: 0;
    }

    /* CSS3 Left Effect */
    article.css3-4 {
        left: -400px;
        bottom: 0;
        -webkit-transition: all .5s ease-out;
        -moz-transition: all .5s ease-out;
        -o-transition: all .5s ease-out;
        transition: all .5s ease-out;
        width: 400px;
    }

    .text a.css3-4 {
        -webkit-transition: all .4s ease-out;
        -moz-transition: all .4s ease-out;
        -o-transition: all .5s ease-out;
        transition: all .4s ease-out;
    }

        .text a.css3-4:hover {
            color: #d0206a;
            text-decoration: none;
        }

    .container:hover article.css3-4 {
        left: 0;
    }

Answer №1

Perhaps I am not fully grasping the concept, but could this example be what you are seeking?

<div class="container right">
    <img src="http://placehold.it/350x150" alt="image" />
    <article class="text css3-4">
        <h1><a href="#" class="css3-4">space1</a></h1>
    </article>
    <article class="text css3-3 css3-4">
        <h1><a href="#" class="css3-3 css3-4">space2</a></h1>
    </article>
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The filter and search function in the table is malfunctioning

Recently, I developed a page designed for saving actors in an array and displaying them in a table. However, my attempt to add a search feature by name failed. If anyone has encountered a similar issue before and knows how to resolve it, please share your ...

The page you are looking for cannot be found (404) because the request method used was

When a seller clicks the button to sell an item, no one else should be able to make an offer after that. The winner must be clearly identified and can access their products on the product page as well as the winners page. The winners page follows a layou ...

Stopping autoplay in Swiper as soon as you hover over it

My swiper is set to autoplay, but I want it to stop immediately when hovered over instead of waiting for the transition to finish. Is there a way to interrupt the transition and stop it at the exact point where the cursor hovers? Here is my Swiper config ...

Discover the interactive world of HTML5 Canvas on iPhone with exciting highlights triggered by touchstart or mousedown

The canvas changes to a darker color when touched and held, reverting back to normal when the touch is released. This effect is similar to how hyperlinks are highlighted on an iPhone, not like text selection. To implement this feature, I am using jQuery t ...

Adding an entry to a table with the events linked to a specific link

Let's imagine we have a table: <table id="myTable"> <tbody> <tr> <td> <a class="removeLink" >Remove</a> </td> </tr> <tr> ...

How can I set the input tag to reset back to 1 when a certain event occurs?

I am currently developing an HTML Snakes And Ladders game. On the settings screen, there is an input field where users can select the size of the board. Depending on their choice, they will be able to choose a maximum number of snakes and ladders. For exa ...

Javascript and iframes may encounter compatibility issues with browsers other than Internet Explorer

My HTML file includes an iframe and JavaScript that function correctly in IE Browser, but they do not work in other browsers such as Safari and Firefox. When using Safari, only the iframe box is displayed without showing the content inside it. I am curio ...

Error in accessing a null property in JavaScript on a different HTML page

My website consists of multiple HTML pages that are all linked to the same JavaScript file containing several IIFE functions. One of the functions is responsible for controlling a specific button that only appears on one page. However, when accessing other ...

What is the process for developing an Alphabetizer Program?

I have been working on this and I am having trouble getting the "alphabetized" version to display. I've tried a few things already, but I'm not sure what is missing or needs to be changed. Any advice on how to fix this would be greatly appreciate ...

Maintaining visibility of entries in collapsed Bootstrap 4 navbar/menu

This is a question that pertains to Bootstrap 4, similar to one found on Stack Overflow, but specific to this version. I am struggling to include right-justified entries in the BS4 navbar that remain visible even when collapsed. I have spent an entire aft ...

Dropdownmenu without borders

I'm having an issue with the dropdown menu on my website - there are no borders showing. I've tried fixing it myself with no luck, so I could really use some help. As a beginner in web development, I don't have much knowledge about these thi ...

The font appears bolder in Chrome once the CSS animation has finished

My CSS animation is causing some unexpected behavior on page load. Once the animation completes, the text suddenly appears thicker than intended, especially when it's a specific shade of red. Curiously, this strange "popping" effect only occurs with ...

Retrieve data quickly and navigate directly to specified div element on page

I am facing an issue with scrolling on my website. While it currently works fine, I would like to make the scrolling instant without any animation. I want the page to refresh and remain in the same position as before, without automatically scrolling to a s ...

Retrieve the HTML source code of a website being displayed in the emulator, all while the script is being executed on the local machine

Can anyone help me with this task? I am trying to retrieve the page source of a web page within the emulator. The script responsible for this task is currently running on my local machine. This script was created using monkeryrunner. If you have any sug ...

Assistance needed to identify CSS issue specifically in FireFox browser

Working on a new webpage and encountered an issue with the HTML markup: <!DOCTYPE html> <html lang="en> <head> <meta charset="utf-8"> <title>TileTabs</title> <link rel="stylesheet" href="css/style.css" t ...

Chrome is where all the action happens, while Firefox prefers to keep things on the left

After a long break, I returned to designing my website and re-learning CSS. My approach involved creating a WordPress-integrated site with minimal HTML/PHP work, focusing more on utilizing the available CSS classes and IDs provided by a template theme (Bla ...

Swap the image (either the last or first child) within a div when it is hovered over

I have multiple Div's on my webpage and I am looking to change the color and image when a mouse hovers over them. Changing the text color from grey to blue is quite simple. CSS #div1:hover{color:#0000CC} If I want to change an image, I can achieve ...

Unable to modify jwplayer css styles to customize the chromecast icon

Is there a way to customize the chromecast icon within the JWPlayer skin to have a specific color? I've identified that the styles I need to change are --connected-color and disconnected-color when inspecting the element. Despite my attempts through ...

Exploring the relationship between CSS z-index values and a canvas

http://jsfiddle.net/y2q3yLpj/ In my example, I tried setting the z-index of a canvas to 0 and the z-index of a div to 1. However, despite this configuration, the canvas appeared higher than the div. Surprisingly, when I set the z-index of the canvas to -1 ...

Exploring for worth using BeautifulSoup

Can anyone help me extract the name of a person (Alex Key) from the following HTML markup: <div class="link_container"> <a class="follow_card" data-uuid="e47443373cfa93d5341ab809f0700b82" data-type="person" data-name="Alex Key" data-permalink="/ ...