Using CSS3 to showcase image captions

I am facing an issue with displaying captions on my images. The caption needs to display in two different ways - normal and hover. To better explain, I have included an image for reference.

Although I have made progress with a large portion of this task, I am unable to correctly show the normal caption on the image.

Can someone guide me on how to resolve this issue?

Below is a snippet of my HTML code:

<div class="slideimages">
    <div id="box-1" class="box">
        <div class="fix-caption">
           <h3>Fix Caption</h3>
           <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit</p>
        </div>                  
        <a href="">     
            <img class="image_scale" src="images/4750.jpg"/>
            <span class="caption scale-caption">
            <h3>Scale Caption</h3>
            <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>
             </span>
        </a>
   </div>
</div>

View my JS FIDDLE link with CSS attached. Thank you.

Answer №1

To resolve the issue of your caption displaying behind the image, you can add the following CSS code:

.fix-caption {
    z-index: 5;
    background-color: white;
}

If adding the above CSS does not work satisfactorily, another solution is to place the elements with the class .fix-caption lower in the DOM order. By doing this, it will give them a higher display order (remember to include a background-color as well).

DEMO 1 (z-index): http://jsfiddle.net/Zfr5c/3/

DEMO 2 (DOM order): http://jsfiddle.net/Zfr5c/2/

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 scroll feature is not functioning properly in detecting the CSS function for the final div

$(document).ready(function() { $(document).on("scroll", onScroll); //smoothscroll $('a[href^="#"]').on('click', function(e) { e.preventDefault(); $(document).off("scroll"); $('a').each(func ...

Reaching SVG with CSS

Is it possible to target SVG elements with CSS? In older versions of IE, they display like broken images and I want to hide them using modernizr. I'm looking for a solution like the following... .no-svg object[type=svg] { display:none; } I have be ...

Adjusting a model using an input is causing a ValueError

Attempting to enable the user to modify a decimal value named 'amount'. Once the user clicks on 'edit', a decimal field will be displayed. Upon finishing the value change and clicking "done"... An error is thrown: Exception Type: Valu ...

Is there a way to dim and deactivate a button after it has been clicked once?

Hello, I am attempting to disable and grey out a button after it has been clicked once in order to prevent the user from clicking it again until they refresh the page. I hope my question is clear enough and that you can understand me. Below is the HTML cod ...

Vuetify's data table now displays the previous and next page buttons on the left side if the items-per-page option is hidden

I need help hiding the items-per-page choices in a table without affecting the next/previous functionality. To achieve this, I've set the following props: :footer-props="{ 'items-per-page-options':[10], &apo ...

What is the correct way to make an image adjust to changes in a browser's size?

I'm in a bit of a quandary: How can I ensure that an image resizes properly based on viewport size? So, here's the challenge - I have an image that is 400 pixels wide and 400 pixels tall. My aim is for it to occupy only 90% of the width of the v ...

The functionality of a pop-up window is not compatible with Google Maps

I recently implemented a script on my webpage that triggers a popup window every time the page is loaded. Here's how the script looks: <!DOCTYPE html> <html> <head> <meta charset=utf-8 /> <title>ColorBox de ...

Tutorial on wrapping HTML content in a CDATA tag using jQuery

Is there a way to enclose some HTML in an element using a CDATA tag to "sterilize" it, so to speak? I've attempted to do so using the following code: $(this).html( "<![CDATA[" + $(this).html() + "]]>" ); However, this approach simply encodes ...

Introducing the World of Wordpress Blogging

How can I create an introduction on my WordPress site similar to the one found at ? I am specifically interested in incorporating the expanding horizon line effect. It seems like it may just be a GIF that plays and then fades into the homepage. Are there ...

The Bootstrap Carousel unfortunately does not provide the option for responsive images

There appears to be an issue with the bootstrap carousel images where they are being assigned a fixed height/width attribute by either views or bootstrap_views. As a result, when the page is resized or viewed on a smaller screen or device, the image gets ...

What could be causing my HTML to not display properly after making changes to a text node?

Can a DOM text node be altered in such a way: node.nodeValue = "foo <strong> bar </strong>" so that it displays the HTML correctly? Appreciate any help. ...

Transform a Microsoft Word table into HTML code

My boss has provided me with a very detailed table in an MS Word document filled with various colors, shapes, and lots of information that I need to incorporate into a website. I attempted saving the Word file as HTML and then transferring the code over, ...

Interactive HTML5 canvas: Dragging and dropping multiple items

I'm currently working on a project that involves allowing users to drag and drop multiple objects within a specified area. To achieve this, I am utilizing the html5 canvas tag. While the functionality works smoothly when dragging and dropping a single ...

Constantly refreshing on its own, the page never stays still

After adding a Facebook login button to my homepage, I noticed that in Firefox, the page refreshes multiple times when you are logged out of Facebook. Any thoughts on why this may be happening? You can check out the page at Thank you! ...

I'm encountering a major issue trying to properly position a background image to fill the entire screen

I am struggling to set a background image that fits the entire screen. It looks great on Windows, but when I view the same page on my mobile device (specifically Android using Google Chrome), the image zooms in and out oddly. Additionally, there seems to b ...

Removing the dividing line between columns in an Antd table: A simple step-by-step guide

Do you notice the lines dividing each table column heading in the image? I want to get rid of these lines from the table. The table component I am using is Antd table. https://ant.design/components/table#examples https://i.stack.imgur.com/Npx5G.png ...

The dynamic breadcrumb feature requires that only variables be passed by reference according to strict standards

Currently, I am working on a website that consists of 3 main layouts: header, main layout, and footer. These layouts are all called by the same controller. The main layout changes depending on the request, but the header and footer remain constant. Within ...

Utilizing DOMXPath to select and click a row within a dynamic table based on the presence of 2 specific innerText values

I am currently working on a project involving Automation Anywhere for automation tasks. One challenge I am facing is how to efficiently click on a row in a dynamically generated table using Object Cloning. Take, for instance: Number | Color | Size | It ...

Unable to trigger mouse event for a div that is positioned on top of an image

Similar Issue: Problem with IE: Transparent div over an image not triggering CSS:hover Greetings, I am currently experiencing a problem with the mouseover and mouseout events for a div that overlaps with an image. I am trying to display hotspots (high ...

What is the best way to add multiple values to a single column but on separate rows?

Attempting to save the question and answer separately in different tables. Successfully stored the question text value, but encountering an error when inserting the answer value. Fatal error: Uncaught exception 'PDOException' with message ...