What is the best way to position text at the bottom of an image using CSS?

Utilizing the jQuery Caption Plugin to showcase the image alt text when hovering over an image.

Currently, the text is displaying at the top but I would like it to show at the bottom. Any suggestions on how to remedy this?

Desired Outcome:

Check out the JSFiddle example here: Sample

Answer №1

By carefully reviewing the manual, you have the option to easily paste this code into your project

$('#wrapper').capty({
  height:   64,
  opacity:  .8
});

Don't forget to add this in your CodePen: CodePen link here

$(function() {
    $('.default').capty({
      height:   64, // Adjust caption height here
      opacity:  .8
    });
});

Answer №2

Here is the updated code snippet for the plugin:

 h.html('<div style="position:absolute;top:210px;">'+j.attr("alt")+'</div>');

To see it in action, check out the demo link: http://example.com/demo

Answer №3

apply styles to div.capty-caption

within this, adjust the height or line-height properties in the css for better results

for example in JQUERY.CAPTY.CSS

div.capty-caption {
    background-color: #000;
    color: #FFF;
    font: bold 11px verdana;
    padding-left: 10px;
    padding-top: 7px;
    text-shadow: 1px 1px 0 #222;
    line-height:---SET 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

Creating a menu that is even more optimized for mobile devices

I recently came across a mobile menu style that I really like: https://www.w3schools.com/html/default.asp What I appreciate about this style is that even on smaller screens, it still displays some main navigation items. This allows for popular links to be ...

Tips on arranging the layout to prevent text from shifting alongside the image

Is there a way to prevent the positioning and size of an image from affecting the layout of my list? I'm new to coding and struggling with this issue in my first project. Any advice or guidance would be greatly appreciated. <!DOCTYPE html> <h ...

Can someone assist me in figuring out how to solve selecting multiple radio buttons at once

<script type="text/javascript"> let x = "1.html"; let y = "2.html"; function redirectPage(form){ for(let i=0; i<form.length; i++) { if(form.answerq[i].checked && form.answerw[i].checked && f ...

How come the subitems of a second-level nested list do not appear when hovering over a hyperlink?

Show "News" in French when hovering over the French option. ul#topmenu li a#HyperLink:hover ul { background-color: pink; display: list-item; } <ul id="topmenu"> <li class="langHorzMenu"> <a href="#" id="HyperLink">French</ ...

To make changes to an item, simply tap on the Catalog number

I'm currently facing a challenge in trying to implement a modal window that displays detailed information about a selected item based on the catalog number. The catalog number serves as the trigger to open the modal. Since I'm relatively new to a ...

Tips on retrieving JavaScript output within an AngularJS model

When I bind the result date to an input text based on the input id, the input value is not saving in the ng model of Angular script. <input type="text" class="form-control" maxlength="10" ng-model="EmployeeSave.HijriDate" onclick="showCal2();" ...

I keep encountering a 404 error whenever I try to access a controller method using Ajax. What could be causing this

In my ValidationController, there is a method named EmailExist. I made an ajax call to the following URL: $.ajax({ type: "POST", url: "/Validation/EmailExist", data: { 'Email': $('#Email').val() }, success: fun ...

Highlight the menu item when you reach a specific section

I am facing difficulties in creating a scrolling menu that highlights the respective item when a specific section is reached. As a beginner in design, I am struggling to achieve this effect. Any insights or guidance on how to implement this would be grea ...

Is using window.postMessage(...) a viable option for facilitating cross domain file uploads?

I'm wondering if there is a way to achieve cross domain file upload using window.postMessage(...) or any other technique. Can anyone help with this? ...

Choose a selection from the options provided

This is a sample for demonstration purposes. I am trying to display an alert with the message "HI" when I click on Reports using the id main_menu_reports. My attempted solution is shown below. <ul class="nav" id='main_root_menu'> & ...

Refine results by searching through the text contained in the elements of every div

I recently came across a helpful fiddle that allows text to be hidden based on what is entered into a search box. However, I am struggling to apply this method to a div that contains multiple elements. Is there a way to modify the jQuery in the provided fi ...

Activate dropdown to trigger a function that fetches dates and disables them in the datetimepicker

I have a dropdown menu containing staff names and StaffId. These are linked to an appointment business logic. I am attempting to activate a select change event where dates stored in the database will be marked as unavailable in the connected jQuery datet ...

Using AJAX to get the response from a static [webmethod] - a guide

On my Default.aspx page, I have the following PageMethod: [WebMethod] public static string Hello() { return "Hello"; } I want to set the text of a div to whatever is returned via AJAX: <div id="ajaxDiv"></div> Below are two methods I us ...

Display a popover by making an Ajax request

When attempting to display a popover on hover of an image, I encounter an issue where the content of the popover is not being shown. This content is retrieved through an Ajax call to a template, which includes a tag used in a taglib that renders the popove ...

Unable to display returned data from an AJAX request made with jQuery autocomplete

After reviewing the debug developer tool, I noticed that the ajax request returned data but for some reason, the data is not being displayed in the text box. The data contains special characters which are visible in the provided image. I am trying to iden ...

Using Jquery ajax within a function

$(function () { $("#rv-title").click(function(event) { $("#rv-content").toggle(); $.ajax({ url: 'index.php?route=check', dataType: 'json', success: function(json) { if (json['output& ...

Unique layout design that organizes calendar using nested divs with flexbox - no

I am having difficulties achieving the desired outcome with my calendar header layout implemented using flexbox for the years, months, and days. What could be the issue? Is it due to the structure of the HTML or is there something missing in the CSS? The ...

resolving table refresh problem with the use of ajax, JQuery, and JSON

I have populated a set of records in HTML table format. Each row includes an anchor tag with a trash-can image at the last column. When this image is clicked, I want to delete the respective row and refresh the table with updated data. My approach involves ...

Leveraging CSS or JavaScript for Displaying or Concealing Vacant Content Sections

I'm working on developing a page template that utilizes section headers and dynamically pulled content from a separate database. The current setup of the page resembles the following structure: <tr> <td> <h3> ...

Ensure that the mask implemented in the form input only shows two decimal places, while simultaneously retaining the original value

Is there a way to format a number in a form input so that it displays only two decimals while still retaining the original value? This is necessary to avoid incorrect values down the line and meets the customer's requirement of showing no more than tw ...