Adjust the size of the clickable region

I'm struggling to figure out how to adjust the click area.

Below are the details:

https://i.sstatic.net/bdbZ8.png

Looking at the image, you can see that the cursor is quite far from the letter, yet it still registers as clickable at that distance.

Here is a snippet of the code to avoid any confusion:

li {
font-size: 20px;
display: inline;
padding-right: 20px;
border: 0px;
}

ul.list li:nth-child(-n+26) a{
font-size: 15px;
color: red;
display: list-item;
z-index: 1;
text-decoration: none;
right: 0;
left: 0;
top: 0;
bottom: 0;
}

.onclick div:target {
display: block;
}

.onclick div:hover {
background-color: red;
color: white;
}
<nav>
  <div>
    <ul class="list">
      <li><a href="pageA.html">A</a></li>
      <li><a href="pageB.html">B</a></li>
      <li><a href="pageC.html">C</a></li>
      <li><a href="pageD.html">D</a></li>
      <li><a href="pageE.html">E</a></li>
    </ul>
   </div>
  </nav>

I've already attempted adjusting the multiple child style, sub nav, and separate LI style, but none of them seem to be effective.

Answer №1

If you want to adjust the width of a tag, you can use the “width” style.

ul.list li:nth-child(-n+26) a{
    width: fit-content;
}

Hopefully, this solution will be beneficial to you.

Answer №2

This information could prove useful:

li {
font-size: 20px;
display: inline;
padding-right: 20px;
border: 0px;
}

ul.list li:nth-child(-n+26) a{
font-size: 15px;
color: red;
display: list-item;
z-index: 1;
text-decoration: none;
position: relative;
margin: 0; border: 0; padding: 0;
float: left;
clear: left;
}

.onclick div:target {
display: block;
}

.onclick div:hover {
background-color: red;
color: white;
}
<nav>
  <div>
  <ul class="list">
    <li><a href="pageA.html">A</a></li>
    <li><a href="pageB.html">B</a></li>
    <li><a href="pageC.html">C</a></li>
    <li><a href="pageD.html">D</a></li>
    <li><a href="pageE.html">E</a></li>
  </ul>
  </div>
</nav>

Answer №3

To resolve the issue, simply include the CSS property display: inline-block in your ul.

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

Bring your images to life with a captivating 3D hover effect

I am looking to achieve a similar effect using JavaScript instead of just pure CSS like the example provided. I'd prefer not to use SCSS either, just sticking to CSS would be great. Please check out this CodePen for reference. .picture-container ...

Is it possible to pass a function as an argument to another function in jQuery?

My function accepts a JSON object as a parameter containing User id, password, success callback, and error callback. The goal is to authenticate the user using an AJAX service. If the service response is successful, I want to call the success callback fun ...

Aligning a div with absolute positioning vertically

There are two elements positioned side by side: an input field and a div. The div is absolutely positioned inside a relative element and placed to the right of the input. The input field has a fixed height, while the height of the div depends on its conte ...

Having trouble getting jQuery JavaScript to work on Wordpress and feeling lost about how to implement no-conflict mode syntax

Trying to implement the code from this Codepen http://codepen.io/eternalminerals/pen/qdGvMo on my WordPress website at I understand that since WordPress is in no-conflict mode, I need to change $ to jQuery. I have made this adjustment and ensured that the ...

What causes the list to shift instead of the image when the vertical-align property of the image is unchecked?

How come when the vertical-align property on this image is unchecked, it affects the list rather than the image itself? Checked: https://i.sstatic.net/NQhf0.jpg Unchecked: https://i.sstatic.net/jS7er.png ...

Exploring Cypress techniques for testing the HTML5 intrinsic validation popup

Is there a way to detect an HTML5 built-in popup validation error while testing an app with Cypress? It seems that this error does not appear in the DOM, making it challenging to capture using a cy command (I am utilizing testing-library). https://i.sstat ...

Is there a way to hide the thumbnail image when the title is hovered over without using CSS?

I'm currently using a simple jQuery script to switch between two thumbnails when hovering over a div. The code works perfectly for the .thumbs class, but I also want this functionality to work with the post titles. Unfortunately, adding the .headline ...

Managing modules within the node_modules folder that have dependencies on .css files

Currently, I am involved in a project where we are utilizing a custom UI library that includes some dependencies. These components come with their own corresponding .css files. The structure of the source code looks like this: |- src |-| |- components ...

Once the database fetches and displays 500 results, the HTML/CSS formatting begins to

On my local webserver, I have a page running off SQLite as its database. Since it is used locally and loads results quickly, displaying all of them on one page isn't a concern. However, I'm facing an issue where the formatting goes awry after 500 ...

Glistening: A variety of designs for textInputs and selectInputs

I am working on styling 2 textInput and 2 selectInput functions, one on a dark background sidebar and the other inside a white bsModal. I want to style them differently. Is there a way to keep the sidebar elements styled one way and change the font and bor ...

Issues with HTML marquee not functioning properly post fadeIn()

I am attempting to create a progress bar using the HTML marquee element. When the user clicks submit, I want to fadeIn the HTML marquee and fadeOut with AJAX success. However, when I click the submit button, the marquee does not fadeIn as expected. Here is ...

Container slide-show fill error

I'm attempting to create a slide show with an overlapping caption that appears when hovering over the container or image. The image needs to fit exactly inside the container so no scroll bar is shown and the border radius is correct. I managed to achi ...

What is the best way to align a set of input fields with their corresponding labels, along with a single button?

https://i.sstatic.net/xSwSH.png I am facing a specific alignment challenge in my project, especially due to the presence of labels. When I group inputs and a button together and use align items center, it works perfectly. However, the labels affect the he ...

Create a div element that expands to occupy the remaining space of the screen's height

I am trying to adjust the min-height of content2 to be equal to the screen height minus the height of other divs. In the current HTML/CSS setup provided below, the resulting outcome exceeds the screen height. How can I achieve my desired effect? The foote ...

Distinctive design for three different list items

Currently working on a project that involves the use of ul and li elements. I need to change the background for every 3rd li element in alternating patterns. Since the li elements are generated from the backend, I do not know how many there will be. I at ...

Using a jQuery if statement to target a particular div and apply custom CSS styling

I have encountered a unique challenge that I am struggling to solve. Imagine I have a 3x3 table created using div elements, and one of the cells has a background color of #999. My goal is to use jQuery to check if a specific cell has this background color, ...

Headers with a 3 pixel stroke applied

I have a design on my website that includes a 3px stroke around the header text to maintain consistency. I don't want to use images for this due to issues with maintenance and site overhead. While I know about the text-stroke property, browser suppor ...

Adding dynamic content to CSS in Next.JS can be achieved by utilizing CSS-in-JS

Currently diving into the world of Next.JS, I've managed to grasp the concept of using getStaticProps to retrieve dynamic data from a headless CMS and integrate it into my JSX templates. However, I'm unsure about how to utilize this dynamic conte ...

Exploring the power of colors in Tailwind CSS and Material UI for your CSS/SCSS styling

Discovering unique color palettes like the Tailwind Color for Tailwind CSS and theMaterial UI colors has been inspiring. These collections offer a range of beautifully named colors from 100 to 900 and A100 to A400, reminiscent of font styles. I am intrig ...

Having trouble getting the CSS class to work in MVC4 with jQuery implementation

I recently created a view page where I implemented some jQuery code: <script type="text/javascript"> $(document).ready(function () { var hdrname = $('#headername').text(); alert(hdrname); if (hdrname == "Pending Assignment") { ...