Implementing full-height list elements using CSS

I'm still facing challenges with my lists...

After receiving some assistance, I was able to create a horizontal list with perfect dimensions for my needs: each element taking up 33.33% width and adjusting its height based on the tallest element. I achieved this by combining regular list items with properties from table and table-cell.

Now, my next task is to wrap the content of each <li> element in an <a> tag to make the entire <li> a clickable link. However, I am finding it challenging as the links do not fill the entire <li> according to the tallest one.

Please take a look at the Fiddle for reference: http://jsfiddle.net/paelzersebbi/mJm6p/4/

The red section needs to span the full height of each <li> element. I cannot use fixed dimensions since it needs to be responsive. Additionally, I require the <div class="one"> container as it is intended to have a background image.

HTML

<ul>
    <li><a href="">
        <div class="one">
            <div class="caption"><h4>Caption 1</h4></div>
        </div>
        <div class="two">
            Here is some text.
        </div>
        </a>

    </li>
    <li><a href="">
        <div class="one">
            <div class="caption"><h4>Caption 2</h4></div>
        </div>
        <div class="two">
            More text here.<br />
            And more content.
        </div>
        </a>

    </li>
    <li><a href="">
        <div class="one">
            <div class="caption"><h4>Caption 3</h4></div>
        </div>
        <div class="two">
            Additional text here.<br />
            Even more content.<br />
            And then some.
        </div>
        </a>
    </li>
</ul>

CSS

ul {
    list-style: none;
    display: table;
    border-collapse: separate;
    border-spacing: 30px 0;
    width: calc(80% + 60px);
    margin: 0 -30px;
    padding: 0;
}
li {
    display: table-cell;
    width: 33.33333%;
    background-color: #FFF;
    vertical-align: top;
    padding: 10px;
    position: relative;
}
a {
    display: block;
    background: red;
}
a:hover {
    background: #CCC;
}
.one {
    height: 100px;
    background-color: #C92;
    position: relative;
}
.caption {
    position: absolute;
    bottom: 0;
}
h4 {
    margin:0;
    padding:5px;
}
.two {
    padding:5px;
}

Thank you for your assistance, I truly appreciate it!

Answer №1

You have the option to utilize pseudo elements with the <a> element in order to expand its clickable/hover area. Check out this DEMO for a visual example.


Make sure to update your CSS accordingly.

a {
    display: block;
    background: red; /* used for demonstration */
    position:relative; /* necessary for absolute pseudo-elements */
}
li {
    overflow:hidden; /* hides overflowing pseudo-elements */
}
a:after {
    content:'';
    position:absolute;
    width:100%;
    height:400px; /* adjust as needed */
    background:inherit; /* for demonstration */
}

Alternatively, you can also consider using this structure: DEMO

<nav> <a> tags </a> <a> tags </a> <a> tags </a> </nav>

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

Is there a method in VBA to access elements generated by javascript code?

After spending several hours conducting thorough research on Google (including browsing StackOverflow), I've been trying to find a method that would allow me to target HTML elements generated by JavaScript in VBA. For instance, using ie.Document.getE ...

Is it necessary to utilize container or container-fluid within the grid system layout?

While similar questions may already exist on Stackoverflow, I believe the exact answer has yet to be found. Many suggest: "You should nest .col within .row, and ensure that .row is inside of .container." However, this concept still eludes me. I underst ...

Refresh numerous HTML <div>'s using data from a JSON object

Looking to automatically update the homepage of my website with the ten most recent "posts" from the server. Here's an example HTML format: <div id="post1"> <p id="link"> </p> </div> <div id="post2"> <p id="li ...

Next.js optimizes the page loading process by preloading every function on the page as soon as it loads, rather than waiting for them to

My functions are all loading onload three times instead of when they should be called. The most frustrating issue is with an onClick event of a button, where it is supposed to open a new page but instead opens multiple new pages in a loop. This creates a c ...

The system encountered an error stating that the class 'Database' could not be found

Whenever I try to establish a connection to my SQL database using my pdo_object.php file, I encounter the following error in my model.php: Fatal error: Class 'Db' not found in /path/model.php on line 8 I have double-checked that all permissions ...

Is there a way for my HTML file to connect with my CSS and JavaScript files stored in an Amazon S3 Bucket?

My current project involves hosting an HTML file as a website on AWS S3 in order to circumvent the CORS Policy. However, when I uploaded all my files into a new bucket, the HTML file was able to open but without accessing the accompanying CSS and JavaScrip ...

What is the best way to ensure email address validation is done perfectly every time?

Can someone assist me with validating email addresses correctly? I am able to handle empty fields, but now I need a way to identify and display an error message for invalid email addresses. How can I modify my validation process to check for improper email ...

When utilizing jQuery to retrieve the height of position:absolute elements, the script is being executed twice, resulting in inaccurate values being returned on

The issue I'm encountering with detecting the height of absolutely positioned content is demonstrated in this JSFiddle. I am working on creating a tabbed panel where users can select a room type and then a sub-type. The sub-types (ul.sub-types) are s ...

Is there a way to determine the bounding rectangle of a specific word within a paragraph when you only have its index?

I am currently developing a text-to-speech functionality for a react application that can emphasize the word being spoken by highlighting it with a background color. This feature closely resembles the layout of the Firefox reader view. However, my curren ...

Getting the full referrer URL can be achieved by using various methods depending

I am currently working with ASP.Net. My goal is to retrieve the complete referrer URL when visitors arrive at my website from: https://www.google.co.il/webhp?sourceid=chrome-instant&rlz=1C1CHEU_iwIL457IL457&ion=1&espv=2&ie=UTF-8#q=%D7%90 ...

The function `jQuery .html('<img>')` is not functional in Firefox and Opera browsers

This particular code snippet jq("#description" + tourId).html('<b>Opis: </b> '+ data); has been tested and functions correctly in Internet Explorer, Firefox, and Opera. However, when it comes to this specific piece of code jq("#i ...

Generate a new JSON reply using the current response

I received a JSON response that contains values for week 1, week 2, week 3, and week 4 under the 'week' key, along with counts based on categories (meetingHash) and weeks. I attempted to merge this data using the .reduce method but without succes ...

Why does jQuery function properly in jsfiddle, but not in an HTML file?

I have been troubleshooting repeatedly, but I am unable to figure out why the jQuery code is not functioning as expected. Strangely enough, it works perfectly in jsfiddle! Here is the HTML code: <!doctype html> <html> <head> <meta ch ...

The Google reCaptcha reply was "Uncaught (in promise) null"

When using reCaptcha v2, I encountered an issue in the developer console showing Uncaught (in promise) null message regardless of moving the .reset() function. Here is the console output: https://i.stack.imgur.com/l24dC.png This is my code for reCaptcha ...

Having difficulty replicating the same effect across all five canvas elements

After following the code provided by j08691 here for canvas, everything worked flawlessly. However, I encountered an error in JavaScript when trying to implement it on multiple canvas elements. As a beginner in JavaScript, I would greatly appreciate any as ...

Issues arise when attempting to display Sphinx documentation containing SVG images on Internet Explorer 11

I have been working on building Sphinx documentation and incorporating a UML diagram generated as an SVG image using graphviz. The SVG file is embedded in the auto-generated HTML template from Sphinx. While the SVG displays perfectly fine on Chrome and Fi ...

What is the best way to make tooltips track a specific data point they are connected to in D3?

I am working with a figure created using D3 that includes tooltips appearing near a data point when hovered over and can be pinned by clicking on the point. I have implemented the functionality to change the plotted values for the points by clicking on spe ...

Tips on resizing images in CSS with accompanying text to prevent overlap

In my school project, I am using cloud9. When utilizing the live preview in a small window pane, my images appear correctly sized. However, upon maximizing my screen browser, the images stack on top of each other and their dimensions increase. My ideal l ...

What is the best way to limit the range slider before it reaches its maximum point?

I am currently utilizing angularjs to stop a range slider at 75%, however, the method I am using is not very efficient and is not working as desired. Is there anyone who can provide guidance on how to achieve this? Please note: I want to display a total ...

make the chosen text appear on Internet Explorer

1 How to insert text into a text box using code? 2 Moving the caret to the end of the text. 3 Ensuring the caret is visible by scrolling the text box content. 4 Programmatically selecting specific text in a textbox. 5 **How to make selected text visible?** ...