The anchor link does not function when viewed in full width

My challenge is creating a list where only the text within each link is clickable, not the entire link. I'm struggling with applying display: block to the anchor while keeping its existing display: table-cell property.

You can view my problem and experiment with your solution here: http://jsfiddle.net/kma_999/v0xkk587/

Thank you in advance!

HTML:

<div class="pane-content">
    <ul>
        <li><a href="#">Kostenkontrolle (Mobile)</a></li>
        <li><a href="#">Sunrise Rechnung</a></li>
        <li><a href="#">Umzug</a></li>
        <li><a href="#">iPhone</a></li>
        <li><a href="#">Telefonieren im Ausland (Roaming)</a></li>
    </ul>
</div>

CSS:

ul {
    border: 1px solid lightgray;
    padding-left: 0px;
}

ul li {
    border-bottom: 1px solid lightgray;
    list-style: none outside none;
    margin-left: 20px;
    margin-right: 20px;
    vertical-align: middle;
}

ul li:last-child{
    border-bottom: 0px solid black; 
}

ul li a {
    display: table-cell;
    height: 75px;
    vertical-align: middle;
    padding-left: 20px;
    color: black;
    width: 100%;
}

ul li a:hover{
    color: black;
    text-decoration: none;
}

ul li a:after {
    content: "\25b6";
    font-size: 10px;
    position: absolute;
    right: 33px;
}

Answer №1

ul {
  display: table;
  border: 1px solid lightgray;
  padding-left: 0px;
  width: 100%;
}

ul li {
  display: table-row;
  list-style: none outside none;
  margin-left: 20px;
  margin-right: 20px;
  vertical-align: middle;
}

ul li:last-child a {
  border-bottom-width: 0; 
}

ul li a {
  display: table-cell;
  height: 75px;
  vertical-align: middle;
  padding-left: 20px;
  border-bottom: 1px solid lightgray;
  color: black;
  width: 100%;
}

You can check out an example

Answer №2

give this a shot

ul li a {
    display: inline-block;
    height: 80px;
    vertical-align:center;
    padding-left: 25px;
    color: #333;
    width: 90%;
    line-height:80px;
}

Answer №3

Feel free to test out the following code snippet:

nav ul li a {
  display: flex;
  height: 60px; // updated height
  padding: 20px 0 0 15px; // updated padding
  color: #333; // updated color
  width: 100%;
}

Answer №4

Check out this example:

ul li a {
    color: black;
    display: inline-block;   // updated styling
    height: 75px;
    line-height: 75px;     // newly included attribute
    padding-left: 20px;
    vertical-align: middle;
    width: 100%;
}

Answer №5

Give this a try:

ul li a {
    display: table-cell;
    height: 75px;
    vertical-align: middle;
    padding-left: 20px;
    color: black;
    width: 500px;
}

I changed the width attribute of the a tag from 100% to match that of its parent element (li). This adjustment appeared to solve the issue.

Answer №6

Give this a shot

ul li a {       
    height: 75px;
    line-height: 75px;
    padding-left: 20px;
    color: black;
    width: 100%;
    display:block;
}

Instead of aligning it vertically in the middle, you can also utilize line-height to make it centered.

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

Avoiding the transfer of values via URL in Node.js

Currently, I'm in the process of developing a login system that involves hashing passwords instead of transmitting them via the URL. The frontend comprises a form through which users input their credentials, which are then compared against the stored ...

I find it difficult to customize columns in grid template areas

I am having trouble adjusting the width of my header's columns to be 24vw, 24vw, 4vw, 24vw, and 24vw respectively. Despite specifying these widths, the browser is rendering all columns with equal width. Specifically, I am unable to change the width of ...

How can I delete a hyperlink on a number from my iPhone or iPad?

Is there a way to prevent certain sets of numbers from being linked, like phone numbers do on iPhones? <h2>Table</h2> <table class="table table-sm table-striped table-hover"> <caption class="sr-only">Search Results</caption> ...

Determining the precise mouse location within child elements regardless of zoom level, scrolling, or dimension changes

My goal is to accurately determine mouse coordinates within the page elements. To see the code in action, please visit: http://jsfiddle.net/t8w9k6gu/ $('#p1, #p2, #p3').on('click mousemove touchmove', function(ev){ var target = ...

Turn off automatic resizing of iframes

I'm currently dealing with a webpage that contains an iframe. The iframe contains quite a bit of data, and every time it loads, its height adjusts to match the content within. Unfortunately, this is causing my page layout to be disrupted. Is there a w ...

How can I assign the output of a function to a variable within a class in Angular?

Is there a way for the Army class to automatically update its CP property with the sum of CP values from all Detachments in the Detachment class? In the Army class, the CP property should reflect the total CP value from all Detachments and be accessible t ...

What is the method of adding a child to the outerHTML of the parent element instead of within it?

Is there a way to use the outerHTML method on a parent element to append a child element so that the icons appear outside of the targeted element rather than inside it? The current code snippet shows the icons inside the box, but I want them to be placed o ...

A 4-image panel grid featuring a central blank space, perfect for an email template design

Attempting to replicate this 4-image layout like the one shown below, but facing challenges due to email template constraints that prevent the use of negative margins. I tried floating the images to the left and using: position: relative; top: -px; but i ...

Tips for aligning and emphasizing HTML content with audio stimuli

I am looking to add a unique feature where the text highlights as audio plays on a website. Similar to what we see on television, I would like the text to continue highlighting as the audio progresses. Could someone please provide me with guidance on how ...

Flip the switch just one time

Hey there, I'm currently working on a JavaScript game and facing an issue. I want to execute a function when an if statement is true, but the function keeps running repeatedly. I need it to run only once. This is my current code: //JavaScript setInte ...

What is the most effective way to shorten a long URL while adding additional parameters?

Having a dilemma here. I am faced with a difficult situation regarding my URL - for example, www.mywebsite.com/first/second/something/index.html. What I would like to do is transform it into something along the lines of www.mywebsite.com/index.html?a=64& ...

Transfer the chosen selection from one form to another on the identical HTML page utilizing Django for the backend operation

I have two forms and I am looking to transfer the selected option from the first form to the second form as a hidden input. Can someone provide assistance on how to achieve this? Below is the attempted solution that did not work: <form id="headerform" ...

Deciphering the ins and outs of the jQuery each function - Surprising

I'm currently trying to understand how the each function works. In this specific scenario demonstrated in this fiddle here, my goal is to iterate through the selected elements of a list box individually. Initially, I anticipated an output like this: ...

Carousel issue with sliding on Bootstrap when deployed on various web servers

I am experiencing a strange issue with my website. I have it installed on two different servers, and while the Carousel works perfectly fine on the first server, it does not slide properly on the second server. Here are the links to each version of the we ...

Disregard the Margin of Ancestor Elements

I'm attempting to make an image span the full width of a parent element, but the parent element has a margin of 10px. This means that when I apply #parent img { position: absolute; top:0; left:0; height: auto; width: 100% } It on ...

Apply a specific class to the div elements that have an image with a designated width

Hello, let's dive into the code. <div class="nyhet"> <img src="#" width="785" class="attachement-full" /></div> <div class="nyhet"> <img src="#" width="390" class="attachement-full" /></div> <div class="nyhet"&g ...

Having trouble eliminating the underline on Vue router-link?

I've experimented with various approaches in an attempt to remove the underline from router-link. This is the code I have: <router-link :to="{name: 'Plan'}"> <div>Plan Your Trip</div> <div class=&apos ...

Intersecting Hyperlink Elements Creating a Hover Effect

I've encountered a perplexing CSS display issue and I'm at a loss for alternative solutions besides simply widening the width of the parent div. Allow me to explain the layout: <div> <ul> <li> <a href="javascrip ...

The dropdown menu is extending beyond the bounds of the screen on mobile devices

When viewing my website on a mobile device, the select dropdown is going off the screen. I am using the bootstrap class form-control. Here is my code: <select name="service" formControlName="service" class="form-control shadow-none" style="width:100%"& ...

The index.html file is unable to read the main.css file specifically on Chrome (desktop) browsers

Currently, my website is being hosted by 000webhostapp.com. It seems to be functioning correctly in all browsers such as Mozilla, Opera, and on mobile devices, but there seems to be an issue specifically with desktop Chrome. After checking with the W3C val ...