The caption below the image is not functioning correctly when hovering over it

I'm having trouble getting the text to appear correctly underneath the image. Whenever I hover over the image, the text seems to overlap it. I am sure there is a simple solution to this issue, but I can't seem to figure it out. Removing the inline display function makes the bullet points visible. Any suggestions on how to fix this?

Here's my current code...

CSS

ul li { 
  float:left;
  text-align: center;
  font-family: Helvetica;
  font-size: 15px; 
  display: inline;
  padding:10px; 
  margin:5px;
  background-image: none;
  position: relative;
}
ul li div {
  display: none; 
  position: absolute;
}

HTML

<div class="ul li">
    <ul>
    <li>
        <div class="caption">About</div>
        <img src='about.png'/>
    </li>
    <li>
        <div class="caption">Portfolio</div>
        <img src='portfolio.png'/>
    </li>
    <li>
        <div class="caption">Resume</div>
        <img src='resume.png'/>
    </li>
    <li>
        <div class="caption">Contact</div>
        <img src='contact.png'/>
    </li>
</ul>
</div>

Javascript

$('ul li').mouseenter(function(){
    var image= $(this).find('img'),
        caption = $(this).find('div');

    caption.width(image.width());
    caption.height(image.height());
    caption.fadeIn();
}).mouseleave(function(){
     var image= $(this).find('img'),
        caption = $(this).find('div');

    caption.width(image.width());
    caption.height(image.height());
    caption.fadeOut();
});

Answer №1

Make sure to set the top property for the specified div element. See the example below.

ul li div {
  display: none; 
  position: absolute;
  top:150px;
}

Adjust the top value according to the image and font size being displayed. For a working example, refer to this fiddle here.

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

Issue with hidden event callback not functioning properly in Bootstrap 3 popover

After studying this example, I attempted to incorporate a hidden callback function. While the show callback is functioning perfectly, the hidden callback seems to be ineffective. Can someone shed light on why this issue is occurring? To showcase the probl ...

Secure Socket Layer (SSL) combined with Asynchronous

Specifics include Apache2, Tomcat6, jdk1.6, struts2, Ajax, and jQuery. My inquiry is: A website that functions flawlessly on Http mode (Apache2 HTTP + Tomcat + Struts2) is facing issues when attempting to work in Https (Apache2 HTTPS + Tomcat + Struts2) ...

Is a Javascript-only application compatible with Amazon S3 cloud storage?

I am currently investigating the validity of the following statement: Based on my research, it seems unlikely to create a web application using only JavaScript - without any server-side logic - hosted on Amazon S3 that can also store data solely on S3 whi ...

Utilize AngularJS to loop through a list with ng-repeat

Seeking guidance as an Angular newbie. The ng-repeat in question is formatted as: ng-repeat="f in drillDownList['D' + d.merchMetrics.DEPT_NBR + 'CG' + d.merchMetrics.CATG_GRP_NBR + 'C' + d.merchMetrics.DEPT_CATG_NBR] M ...

Having trouble passing data from router to View with EJS in Express. Despite trying, still encountering ReferenceError message

I encountered an issue when trying to display form errors to the user. I attempted to pass the errors from the router to my view file. Error Message ReferenceError: e:\2016\passport\views\register.ejs:38 36| 37| <div ...

Enhance your website with a multi-column Pure CSS drop-down menu

Can anyone help me with this issue I'm facing? I am struggling to add a second column to the main "Authorized Brands" menu, and when I tried to break it up, it affected the rest of the columns due to the width being set at 1000px. This is the code I ...

Using the power of jQuery and Ajax to smoothly transition to a different page after editing the value of

Displaying a MySQL table named demo with the values Peter and John along with edit links Example Peter EDIT John EDIT When the edit link is clicked, it will open the page edit_name.php. In edit_name.php, you can update the clicked value using the updat ...

Customizing Material-UI styles using makeStyles

Currently, I am in the process of building a small portfolio website. Despite my attempts to style an avatar using the makeStyles class, it seems that the Mui avatar root is overriding my desired styling. I am wondering if there is a way to achieve this w ...

Tips for passing arguments to event handlers in React JS

While going through the React JS documentation, I came across the concept of "Lifting State Up" and I have some confusion about it. You can check out the codepen sample here: https://codepen.io/valscion/pen/jBNjja?editors=0010 In the TemperatureInput comp ...

Refresh the NodeJS page without resending user data

I am facing an issue with my Node Js local server and multiple identical html pages. Each page contains user input fields that are saved on a text file. The problem arises when users refresh the page, as the data from the previous page is sent and saved ag ...

Send the data from a table to a Python method in Flask using AJAX

Recently, I picked up on flask and decided to create a small web tool for organizing data. The main page displays a table of list numbers and their respective descriptions. I managed to implement jQuery functionality that allows double clicking to select i ...

Need assistance as require function is not functioning as anticipated

const THREE = require('three'); require('three/examples/js/loaders/OBJLoader.js'); Once I imported threejs from node_modules, I decided to utilize the provided OBJLoader, but encountered an unexpected error. THREE is not defined a ...

Unnecessary Page Diversion

Within my index.php file, I have a download button with the id of "render". Using AJAX, I am sending a request to the server. The JavaScript code being utilized is as follows: $('#render').click(function(e){ $('html,body').animat ...

Can Angular-Material help create a sidenav that toggles on and off?

I am struggling to create a side menu that remains closed by default on all screen sizes and always opens on top of other content. Despite my efforts, it keeps switching at widths over 960px. This is the current code for my menu: <md-sidenav is-locked ...

What is the process of extracting a URL and inputting it into a form to enhance

Can anyone help with extracting a specific value (TEXT) from a URL and automatically paste it into an input form field? For example, if the URL is domain.com/page?code=123abc, I need to grab the code (in this case, 123abc) and have it automatically popula ...

What is the best way to add a button to every row in Titanium Studio?

Is there a way to add a different button inside each row (createTableViewRow)? I have created five buttons using Titanium.UI.createButton, but I'm struggling to figure out how to place all five buttons in every row. Can someone provide some guidance o ...

Why are the icon pictures not displaying in Angular's mat-icon-button?

Recently, I stumbled upon a snippet of code in an Angular project that caught my eye. Naturally, I decided to incorporate it into my own program: <div style="text-align:center"> <a mat-icon-button class="btn-google-plus" href="http://google.com ...

Attempting to display the todo item in the form of <li>, however, the todo.name property is not

I am currently developing a task manager application and have encountered a puzzling issue: When I include the Todo component within the TodoList component and pass the todo item as a prop todo = {name: "ssss", status: false, id: 0.0289828650088 ...

The code loses track of the chosen ID

I am having issues retrieving multiple data from a database using two functions. The first function works fine, but when the second function is executed, it appears that the ID is being forgotten. Can anyone assist me in resolving this issue? First and fo ...

Developing a feature that triggers once a new element materializes

When using the .append method in jQuery to create an element, I need to run a function as soon as that element exists. However, I've noticed that right after running the append command, the element is not yet in existence. So, how can I ensure the fun ...