CSS is currently unable to render text overlay on the screen

I've been working on implementing this code snippet into my website, but for some reason it's not displaying correctly. I'm using the exact same code that's available on this fiddle: http://jsfiddle.net/2tPGy/3/

Here's the HTML:

    <ul class="projectGrid align">
        <li id="project-1">
             <a href="#">
                 <div class="img-overlay">
                     <h4>Title</h4>
                     <p>A description of the image</p>
                 </div>
             </a>
        </li>
      </ul>

And here's the CSS:

  .projectGrid li {
 display: inline-block;
 margin: 0 20px 20px;
 box-shadow: 0px 0px 8px rgba(0,0,0,0.2);
 opacity:0.7;
 border-radius: 11px;
 -moz-border-radius: 11px;
 -webkit-border-radius: 11px;

 text-indent: -9000px;
-webkit-transition: box-shadow .25s  ease-in-out, opacity .25s ease-in-out;
-moz-transition: box-shadow .25s  ease-in-out, opacity .25s ease-in-out;
-o-transition: box-shadow .25s  ease-in-out, opacity .25s ease-in-out;
-ms-transition: box-shadow .25s  ease-in-out, opacity .25s ease-in-out;
 transition: box-shadow .25s  ease-in-out, opacity .25s ease-in-out;

 }  
   .projectGrid li a {
   display: block;
   width: 280px;
   height: 280px;
   background-color: grey;
   border: solid;
   border-radius: 11px;
  -moz-border-radius: 11px;
  -webkit-border-radius: 11px;
  } .projectGrid li:hover {
   box-shadow: 0px 0px 8px rgba(0,0,0,0.7);
   opacity:1.0;

  }
 #project-1 {
    height:286px;
    overflow:hidden;
    position:relative;
    width:286px;
 }
.img-overlay {
    background-color:#000;
    bottom:0;
    color:#fff;
    opacity:0;
    filter: alpha(opacity=0);
    position:absolute;
    width:100%;
    z-index:1000;
}
#project-1:hover .img-overlay {
    opacity:0.75;
    filter: alpha(opacity=75);
    transition:opacity 0.25s;
    -moz-transition:opacity 0.25s;
    -webkit-transition:opacity 0.25s;
}
#project-1 a {
    background: url('../images/1.png') no-repeat scroll;
    background-size: 280px 280px;
}

The code functions properly on the fiddle, however when implemented on my website, the text within the div is not visible. Any suggestions on what might be causing this issue?

Answer №1

The <ul> element was mistakenly written as <ui> and it was not properly closed in the code snippet provided. For an updated version on jsFiddle, please visit: http://jsfiddle.net/KwyDt/3/

<ul class="blah">
  <li id="project-1">
      <a href="#">
      <div class="img-overlay">
          <h4>Title</h4>
          <p>A description of the image</p>
      </div>
      </a>
  </li>
</ul>

In addition, the usage of <a href="#"></a> wrapping around a <div> is incorrect. It may be necessary to clarify the desired outcome as the current structure is confusing and difficult to interpret. There seems to have been some improvements made, but the formatting of the code still raises doubts about its functionality.

Answer №2

Take a look at my version of your jsFiddle. Does this fit your needs? Instead of adjusting the opacity, I recommend using display:none on the standard .img-overlay CSS class, then switching to display:block on :hover. Can you implement this on your website? I've also incorporated @Giacomo1968's suggested fixes regarding the unclosed ui tag, assuming you meant ul.

Can you explain the inclusion of this line?

text-indent:-9000px;

I have removed that and now everything seems to be working smoothly in the updated jsFiddle example. Please let me know if this resolves any issues on your end.

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

Incorporating HTML5 Video Using an AJAX Request

I am attempting to fetch a video using an ajax query, but it seems that the video player control buttons are missing. Here is the code I am using: $.ajax({ context: document.body, url: "/?get=json&act=video", type: "get", success: fu ...

Is there a datepicker that combines both a month view and event view?

Looking to implement a unique datepicker style. I've experimented with several plugins, but have yet to find a solution that fits my requirements. Specifically, I want the ability to click on the month displayed on the left side of the datepicker to ...

What is the reason behind the HTML button producing the 'ul' node just once even after being clicked multiple times?

Just to clarify, the code below is successfully doing what I intended. I am currently developing a basic todo application. Each time the button on the page is clicked, it triggers the createListElem() function. The initial line of code in this function ap ...

Step-by-step guide on downloading an image in HTML with the click of a button

I have a photo gallery on my website created using PHP and HTML. I am looking to add a functionality where users can click on a button to download the image that is currently set as a background of a specific div element in the gallery. The download button ...

Applying media queries to incorrect screen sizes

My media query seems to be behaving oddly. @media only screen and (max-width: 1200px) { .tool-panel { margin: 0px 24px 0px 0px; } } It is getting applied at 1183.20px instead of 1200px. This discrepancy is consistent across all browsers ev ...

Create a CSS border with a stylish downward arrow design

Recently, I came across a specific requirement that I need help with. You can see the image https://i.sstatic.net/j4Qdf.png. I found a helpful resource on how to create triangles using CSS on https://css-tricks.com/snippets/css/css-triangle/. However, I a ...

Refrain from showing content beneath a certain element

Is there a way to hide all content that appears after a specific element, such as a particular class of div? The issue I am facing involves using a 1&1 webpage builder with a restrictive layout-template enforced by my boss. I am trying to remove the foote ...

Activate Materialize Css Tooltip with a click to reveal its content

How can I make the tooltip appear when clicked? Here is my code. Your assistance would be greatly appreciated. <a href="javascript:;" class="tooltipped info_circle" data-position="bottom" data-delay="50" data-tooltip="Numbers should MUST be 5 digits. N ...

Tips for arranging various HTML elements in a horizontally aligned row within a Bootstrap scrollbar

I am encountering challenges with the frontend of my webapp. I utilized Bootstrap along with some customized CSS definitions for adjustments. While the desktop interface appears fine, there is an issue with the navbar on smartphones. When attempting to scr ...

Three divs arranged side by side with responsive design for mobile viewing

This code generates 3 divs for display. However, I am looking to optimize them for mobile devices. What steps can I take to accomplish this? Currently, the divs are oriented to the left and are not visible on a mobile device. I would like them to display ...

angular index.html code displayed

I successfully deployed an Angular app on a server in the past without any issues. The Angular version is 6.1.1, Angular CLI version is 6.2.9, npm version is 6.13.4, and node version is 10.18.0 for both local and server environments. The server is running ...

What is the procedure for assigning a value to an elrte editor?

I'm currently updating a page and I'm having trouble figuring out how to set the value of elrte. Can anyone help? <textarea id="ehtml"></textarea> .. $(document).ready(function() { $('#ehtml').elrte(opts_edit); $(& ...

The CSS dropdown menu ends up being positioned underneath the slideshow

Currently, I am working on creating a CSS dropdown menu using CSS3. However, I have encountered an issue where the dropdown menus are going under the slideshow on the page when hovered, making the dropdown items invisible. I am unsure whether I should fix ...

CSS: Fixed item at the bottom of a container that scrolls horizontally

I am working on creating a sticky footer within a horizontally scrolling element. I want the sticky footer to be positioned at the bottom, adjust its height based on the content inside it, and match the width of the scrollable parent (in this case 200px). ...

Verify with PHP

I am looking to add a simple button on my HTML page that can trigger my PHP script when right-clicked. I have attempted to do this with the code below, but unfortunately, I haven't had much success so far: //My html code <!DOCTYPE html> <hea ...

Having trouble with your jQuery dropdown menu? :)

I am currently developing my own drop-down menu and below is the code that shows hidden sub-menus: jQuery('ul li').hover(function(){ jQuery(this).children('ul').stop().show().animate({ opacity: 1 }); }, function() { jQuery(this).ch ...

jQuery/MVC3 script not triggering onclick event after initial execution

Hey there, I'm having an issue with a function that is triggered when clicking on an image. It seems to only be called once even though I expect it to be called multiple times. Here's the JavaScript code, combined with a bit of razor syntax, tha ...

Unique styling implementation for element situated underneath Angular 6 router-outlet

I'm currently working on implementing router transitions in my Angular application, and I've encountered an unusual problem. The styling for the router-outlet element is being applied to the element that comes after it in the DOM hierarchy. Here ...

I am interested in creating a class that will produce functions as its instances

Looking to create a TypeScript class with instances that act as functions? More specifically, each function in the class should return an HTMLelement. Here's an example of what I'm aiming for: function generateDiv() { const div = document.crea ...

Retrieve all information contained within the HTML tags <div align="center"></div> using Java programming

I am new to Java and feeling a bit overwhelmed since I have no experience with it. With Selenium, I was able to download the HTML of a page and store it in a string. Now, my goal is to extract all the data between <div> tags and populate an array wit ...