Struggling to overlay HTML text on top of the image on the right

I'm having a strange issue with my e-commerce site homepage. I want the line of HTML text that says SHOP BAGS to appear over a specific image, but it's showing up on the wrong one. I've tried wrapping the desired image in its own div and adjusting the CSS, but I can't seem to get it right. I don't want to change the absolute positioning, and it shouldn't be necessary anyway. Can someone take a look and suggest a solution?

Answer №1

When working with absolute positioned elements, it's important to consider their positioning in relation to the nearest relative element. To keep absolute position boundaries contained within a specific area, you can set the parent element's position to relative.

.thumbnail a {
     position: relative;
     display: block;     
 }

In this scenario, applying the above code would be beneficial as the .text-content element is positioned within the a tag.

.thumbnail a {
    position: relative;
    display: block;     
}

span.text-content {
    position: absolute;
    top: 10px;
    left: 15px;
    color: #fff;
    font-size: 24px;    
}
<div class="thumbnail">
    <a href="">
        <img src="http://placehold.it/580x278/333333/" alt="" />
        <span class="text-content"><span>Shop Buckets</span></span>
    </a>
</div>

<div class="thumbnail">
    <a href="">
        <img src="http://placehold.it/580x278/333333/" alt="" />
        <span class="text-content"><span>Shop Bags</span></span>
    </a>
</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

Tips for positioning a div to match the height of its parent div

How can I make a div stretch to the height of its parent using Bootstrap 3.0.2 without using a script? Check out the fiddle linked below. In this example, I want to stretch the blue container to match the height of the parent green container. View Fiddle ...

CSS: the enigmatic padding of absolute positioning within a table cell

I am encountering an unusual issue while attempting to position a div element absolutely inside a table-cell. In order to achieve absolute positioning, I utilize a wrapper div element with position:relative: HTML <table> <colgroup> ...

Hovering over a link in the navigation bar causes additional spacing

HTML: <ul> <li><a href="#">Home</a></li> <li><a href="#">Products</a> <ul><a href="#">Power tools</a></ul> <ul><a href="#">Decorating</a>< ...

What causes my HTML files to become corrupted after uploading them?

After uploading my html, css and js files through Pydio, I noticed that my website appears to be messed up. Can anyone provide insight into what may have gone wrong and how to fix it? While some of the Google fonts I included are displaying properly, othe ...

Animating a div's width with CSS from left to right

My goal is to create an animation effect for two overlapping divs that will reveal or hide the text inside them. I want one div to animate from left to right while the other animates from right to left, creating a wiping effect where as one piece of text d ...

The navigation bar seems to be missing from the page

I am currently working on developing a responsive navigation bar with CSS animation. However, I am encountering some issues when trying to run the code on my laptop. Upon running it, only the checkbox appears while the list of navigation items is displayed ...

Data not getting transmitted to Rails controller via AJAX request

My development setup includes Rails 5.2.4, coffee-rails 4.2, jquery-rails 4.4.0, and jquery-ui-rails 6.0.1. I've successfully implemented functionality that allows users to drag around and resize divs on a web page. However, I now need to save the ne ...

Use jQuery to parse the JSON below and then showcase the information in an HTML table

Can anyone assist me with parsing the following JSON using jQuery and presenting it in an HTML table? I want to showcase the values of "key" and "doc_count" in an HTML table. Your help would be greatly appreciated. Please find the JSON data below: { ...

I wish to have the option to choose a courseId when creating a new hole by clicking the "create new hole

I'm currently developing a golf score tracking application. I have set up a database with tables for Rounds, Courses, and Holes. The Hole table contains a foreign key that links to the CourseId, allowing me to associate each hole with a specific cour ...

"Can the form and action occur on the same page, or should they be

When it comes to form actions, what is more effective: having the action on the same page or a different page? See the sample code below: <form action="act.php"> html code </form> <form action=""> html code </form> < ...

Tips for incorporating an icon into a bootstrap card along with a title and text on the same line

Struggling to include an icon in a bootstrap card? Want the icon, title, and text all in the same row? I attempted using float left on the card icon, but it didn't have the desired effect. Any suggestions on how to achieve this successfully would be g ...

Is it possible for CSS to accurately crop images by pixels [Sprite Box]?

I attempted to replicate the math used for the previous image cuts and added my own image, but it appears blank. Can you identify where the issue lies? #paymentForm { -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; -webk ...

Showcasing specific options on radio button selection

My goal is to show specific forms based on the selection of particular radio buttons. Below are the radio buttons available: <input type="radio" name="condition" value="working" id="condition"> <input type="radio" name="condition" value="working ...

Simple code styling tool

Seeking guidance to create a basic syntax highlighter using JavaScript or ClojureScript. While aware of existing projects like Codemirror and rainbow.js, I'm interested in understanding how they are constructed and looking for a simple example. Do th ...

The backend is serving HTML content, but the frontend is not initiating any redirects

After hitting an API endpoint and examining the network call responses, I identified that the HTML response returned with a status code of 302. Despite this, I am perplexed as I do not witness the expected redirect on the user interface. The intended redir ...

What techniques does DeviantArt use to adapt and adjust the content displayed on a page based on the width of the user's

Visit and observe the functionality where new content appears as you widen your browser window. The alignment of the content in the center is a key aspect of this design on DeviantArt's website. How is this achieved? I attempted to create a div with ...

What steps can be taken to create a progress bar in the input field that spans the entire width of its parent div, reaching

I received assistance from a friend in creating this progress bar. Everything seems to be working well, except for the fact that the progress bar is not extending to the full width of the parent div. The new width after each input tag is entered using Java ...

What is the best way to format code across multiple paragraphs?

I am looking to create a website with an abundance of paragraphs, but I am curious if there is a more efficient method for spacing the content in the code without manually inserting <p> tags for each paragraph. It seems like it may require more than ...

An issue with JSPDF arises when used on mobile devices

Currently, I am working on a project to create a responsive web application, which involves utilizing JSPDF for generating PDF reports directly from HTML. For a demonstration of the functionality, you can check out this Demo. Unfortunately, when trying t ...

Struggling with aligning rows containing three divs each in Rails and bootstrap

Looking to display 3 article divs in each row on my website using bootstrap 3 grid system: <div class="container-fluid"> <h1>NEWS</h1> <div class="row"> <% @articles.each do |article| %> <div class="col- ...