Hovering over images for captivating captions in html and css

I'm currently experimenting with creating an image caption hover animation and here is the progress I've made: https://jsfiddle.net/6Lwo2231/

Here's a snippet of the HTML code:

<div class="container-a1">
    <ul class="caption-style-1">
        <li>
            <img src="http://i68.tinypic.com/b8js6p.jpg" alt="" />
            <div class="caption">
                <div class="blur"></div>
                <div class="caption-text">
                    <h1>Friends</h1>
                    <p>Whatever It Is - Always Awesome</p>
                </div>
            </div>
        </li>
    </ul>
</div>

And here's a section of the CSS code:

.caption-style-1{
list-style-type: none;
margin: 0px;
padding: 0px;

}

.caption-style-1 li{
    float: left;
    padding: 0px;
    position: relative;
    overflow: hidden;
}

.caption-style-1 li:hover .caption{
    opacity: 1;
}

/* More CSS code... */

My goal is to make the caption visible without needing to hover over it, and when hovering over the image, move the caption downwards to the center and display an arrow image for navigating to another page, similar to this example image.

Your assistance would be greatly appreciated. Thank you!

Answer №1

Here's the solution I came up with. https://jsfiddle.net/6Lwo2231/3/

To customize the arrow, simply replace the arrow span with your desired arrow image.

What I included:

HTML code:

<div class="caption-text">
        <h1>Friends</h1>
        <p>Whatever It Is - Always Awesome</p>
        <span class="arrow-link">ARROW IMG HERE</span>
</div>

CSS code:

.caption-style-1 li:hover .blur{
    opacity: 1;
}

.caption-style-1 li:hover .caption-text{
    top:20px;
}

.caption-style-1 li:hover .arrow-link{
    opacity: 1;
}

.caption-style-1 .caption-text{
    z-index: 10;
    color: #fff;
    position: absolute;
    width: 320px;
    height: 240px;
    text-align: center;
    top:0px;
    -webkit-transition:all 0.45s ease-in-out;
    -moz-transition:all 0.45s ease-in-out;
    -o-transition:all 0.45s ease-in-out;
    -ms-transition:all 0.45s ease-in-out;
    transition:all 0.45s ease-in-out;
}

.caption-style-1 .blur{
    opacity: 0;
    background-color: rgba(0,0,0,0.65);
    height: 300px;
    width: 400px;
    z-index: 5;
    position: absolute;

    -webkit-transition:all 0.45s ease-in-out;
    -moz-transition:all 0.45s ease-in-out;
    -o-transition:all 0.45s ease-in-out;
    -ms-transition:all 0.45s ease-in-out;
    transition:all 0.45s ease-in-out;
}

UPDATE: @tinkerbelts provided a revision. https://jsfiddle.net/6Lwo2231/5/

The issue identified was in this snippet of code:

.caption-style-1 img{
        margin: 0px;
        padding: 0px;
        float: left;
        z-index: 4;
    }

A left float was mistakenly applied to all images within the caption, including the arrow.

Answer №2

Do you mean like this? https://example.com/code-example

To achieve the desired effect, you need to adjust the positioning of the element with the class .caption-text. This can be done by specifying a new position for the CSS selector

.caption-style-1 li:hover .caption-text
when the list item is hovered over.

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

When a page is being redirected using requestdispatcher in a filter, the CSS contents do not seem to be applying correctly

Upon evaluation of the condition, if it fails, I am utilizing a request dispatcher to redirect to another page. The redirection is successful, however, the CSS is not being applied to the new page. What could be causing this issue? public class RolePrivil ...

Creating a cross-platform file writer with PHP and JavaScript

My current challenge involves using buttons on an HTML page to trigger a PHP program that writes to a text file. Despite receiving a success message from my Ajax function, the file that should have been written to doesn't exist. Here's a snippet ...

Failure to properly evaluate the ID string in Express

I'm currently developing an express app and I am facing an issue with adding a friends list on a user's profile page. The user has an array of friends, which is essentially an ID pointing to another user. However, when comparing this ID to the us ...

Trouble viewing Three.js content in Index.html

My current project involves building a website using three.js with typescript. However, I am facing an issue where only the header from my index.html file is displayed when I try to load the website onto a local server. The main problem arises when I atte ...

Having trouble inserting a new list item within a Bootstrap tab

I have a question regarding the creation of a tabbed interface using the code below: <ul class="nav nav-tabs"> <li class="active"><a href="#">Chart 1</a></li> <li><a href="#">Chart 2</a></ ...

Issues with Image and Product Name Rendering in Outlook for Windows

Having a bit of trouble with Outlook PC not cooperating with my product images and names. While other email clients show the product names below the images as intended, Outlook PC is causing the names to appear next to the images like this - Product name ...

What separates $(document).ready() from embedding a script at the end of the body tag?

Can you explain the distinction between running a JavaScript function during jQuery's $(document).ready() and embedding it in the HTML within script tags at the bottom of the body? Appreciate your insights, DLiKS ...

The html element is failing to adjust its height to match the entirety of the browser window, even when set to

After inspecting my HTML element, I noticed that it isn't occupying 100% of the browser view, even though I have set the height to 100% in my CSS file. I tested it in both Chrome and Firefox, and the issue persists. I suspect that the browser is addin ...

Refresh the content of an iframe (local HTML) by clicking on buttons

When a user clicks on a button, I am loading an HTML file into a DIV (iframe). The issue arises when the user clicks another button and wants to reload the iframe with a different HTML file. This is the current code snippet: <script type="text/javasc ...

The inclusion of a new class in the div element is causing unnecessary page duplication

I'm attempting to designate a small section of text on my mobile webpage as the only part to be printed, specifically on a 62mm x 52mm brother label printer label. Below is the CSS I've implemented: @page { size: 62mm 52mm; marg ...

Floating action button within a collapsible panel

I am having trouble placing a fixed-action-btn inside a collapsible body. It keeps appearing in the bottom right corner of the page instead of within the collapsible itself. How can I ensure that the button stays inside the body? Check out this link for r ...

Modify the css file in swift or obj c without the need for javascript

Is there a way to modify the font, font color, and font size of an HTML page? I have successfully converted the CSS file into a string by using String(contentsOfFile). Is it possible to use regular expressions or something similar to make changes to the CS ...

Avoid duplicate borders on columns that adjust their size based on the screen width

Picture yourself utilizing Bootstrap 4 and displaying various cells, each with unpredictable numbers. .cell { border: 1px solid black; } <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"> < ...

Is it feasible to decrease the lateral margins of Bootstrap's container without the need for custom CSS? If so, what is the method?

My web page includes several screenshots to illustrate the issue I am facing. One of my challenges is the scroll bar below the table, which I find displeasing. In an attempt to resolve this, I decided to adjust the lateral margins slightly. Here's a s ...

Tips for identifying repeating id numbers within a form?

I recently completed a form with approximately 800 fields, only to realize that I accidentally gave some of the fields the same ID. Can someone please advise me on how to track down these duplicate IDs? ...

Ways to make a button blink using AngularJS

Currently working on an AngularJS SPA application where a button is present in the front-end HTML page. When this button is clicked, it triggers an operation which takes some time to complete. I want to inform the user that the operation is still in prog ...

Fine-tuning CSS layout based on perspective alteration

I am working with the following code: function exportTableToExcel(tableID, filename = ''){ var downloadLink; var dataType = 'application/vnd.ms-excel'; var tableSelect = document.getElementById(tableID); var tableHT ...

placeholder for selecting a file

I'm struggling to replace "no file chosen" with "cv" on the file input field. I tried adding a placeholder, but it didn't work as expected. https://i.sstatic.net/wQqcS.png <div class="col-md-6 form-group "> ...

Platform designed to simplify integration of high-definition imagery and scalable vector illustrations on websites

In the ever-evolving world of technology, some clients support advanced features like svg while others do not. With the rise of high resolution devices such as iPhone 4+ and iPad 3rd gen., it has become crucial to deliver graphics that can meet these stand ...

Steps for designing image animations with fade in and fade out effects

I have a task to enhance the current code provided below, which currently works with only two images. HTML: <div id="cf"> <img class="bottom" src="<?php bloginfo('template_directory') ?>/assets/img/image1" /> <img class ...