Trying to reduce the cursor box area within an A link containing a div box

My communication skills are lacking, so I have included an image to better illustrate my issue.

Here is the problem

.body {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.flex-container {
  display: flex;
  flex-direction: row;
  justify-content: center;
  cursor: default;
}

.column1 {
  display: flex;
  flex-direction: column;
}

.boxhunter {
  display: flex;
  padding: 5px;
  flex-direction: column;
  align-items: center;
  width: 180px;
  background-image: radial-gradient(circle at center center, #ABD473 0%, #16150c 120%);
  border: 2px solid black;
  border-radius: 3%;
  margin: 10px;
}

a {
  color: black;
  font-family: Dwarvesc;
  border: 1px dotted red;
  padding: 5px;
}
<div class="body">
  <div class="flex-container">
    <div class="column1">
      <a href="./classes/druid/druidindex.html">
        <div class="boxdruid"><img class="profsimage" src="./randomimages/driud.png">Druid</div>
      </a>
      <a href="#hunter">
        <div class="boxhunter"><img class="profsimage" src="./randomimages/hunter.png">Hunter</div>
      </a>
      <a href="#mage">
        <div class="boxmage"><img class="profsimage" src="./randomimages/mage.png">Mage</div>
      </a>
      <a href="#paladin">
        <div class="boxpaladin"><img class="profsimage" src="./randomimages/paladin.png">Paladin</div>
      </a>
    </div>
    <div class="column1">
      <a href="#priest">
        <div class="boxpriest"><img class="profsimage" src="./randomimages/priest.png">Priest</div>
      </a>
      <a href="#rogue">
        <div class="boxrogue"><img class="profsimage" src="./randomimages/rogue.png">Rogue</div>
      </a>
      <a href="#warlock">
        <div class="boxwarlock"><img class="profsimage" src="./randomimages/warlock.png">Warlock</div>
      </a>
      <a href="#warrior">
        <div class="boxwarrior"><img class="profsimage" src="./randomimages/warrior.png">Warrior</div>
      </a>
    </div>
  </div>
</div>

In the provided CSS code, the dotted red lines indicate the box wrapped by the A link. I would like the entire box to be clickable while maintaining a default cursor position between each box. Is there a way to change the A link to target only the div box? Thank you for your assistance.

Answer №1

Your HTML layout doesn't require any changes.

Solution to your issue lies in modifying just 2 lines of your CSS!
The problem was related to a simple padding/margin inconsistency.

Below is a functional code snippet with comments indicating the modifications made:

.body {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.flex-container {
  display: flex;
  flex-direction: row;
  justify-content: center;
  cursor: default;
}

.column1 {
  display: flex;
  flex-direction: column;
}

[class*="box"] { /* Class changed for testing */
  display: flex;
  padding: 5px; /* Adjusted padding */
  flex-direction: column;
  align-items: center;
  width: 180px;
  background-image: radial-gradient(circle at center center, #ABD473 0%, #16150c 120%);
  border: 2px solid black;
  border-radius: 3%;
  /* margin: 10px; Removed */
}

a {
  color: black;
  font-family: Dwarvesc;
  border: 1px dotted red;
  margin: 15px; /* Margin modified */
}
<div class="body">
  <div class="flex-container">
    <div class="column1">
      <a href="./classes/druid/druidindex.html">
        <div class="boxdruid"><img class="profsimage" src="./randomimages/driud.png">Druid</div>
      </a>
      <a href="#hunter">
        <div class="boxhunter"><img class="profsimage" src="./randomimages/hunter.png">Hunter</div≫
      </a>
      <a href="#mage">
        <div class="boxmage"><img class="profsimage" src="./randomimages/mage.png">Mage</div>
      </a>
      <a href="#paladin">
        <div class="boxpaladin"><img class="profsimage" src="./randomimages/paladin.png">Paladin</div>
      </a>
    </div>
    <div class="column1">
      <a href="#priest">
        <div class="boxpriest"><img class="profsimage" src="./randomimages/priest.png">Priest</div>
      </a>
      <a href="#rogue">
        <div class="boxrogue"><img class="profsimage" src="./randomimages/rogue.png">Rogue</div>
      </a>
      <a href="#warlock">
        <div class="boxwarlock"><img class="profsimage" src="./randomimages/warlock.png">Warlock</div>
      </a>
      <a href="#warrior">
        <div class="boxwarrior"><img class="profsimage" src="./randomimages/warrior.png">Warrior</div>
      </a>
    </div>
  </div>
</div>

Trust this information proves beneficial to you!

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

What is the best way to emphasize the current page within my Bootstrap <nav> menu?

Below is the Bootstrap code that defines our main menu navigation: <div class="col-xl-9 col-lg-9"> <div class="main-menu d-none d-lg-block"> <nav> ...

Please indicate a width of 3 characters for the HTML input text

Is there a way to create an HTML text box that can only fit 3 characters exactly? I came across this code online: <input type="text" style="width: 10px; padding: 2px; border: 1px solid black"/> This code creates a text box with a width of 10px ...

Prevent the rendering of HTML in the combobox dropdown menu

Utilizing ExtJs 3.1 In my Ext.form.ComboBox, the store includes values such as: "value1", "<value2>", "value3". The issue arises when the combobox dropdown list is displayed, and "<value2>" is being interpreted as an HTML tag. This is causing unwant ...

Adjust the checkmark color of MUI Checkbox

When using Material UI's MUI library for React, I encountered an issue with the checkbox checkmark color. By default, the checkmark takes on the background color of the container element, which is great for light backgrounds but not ideal for dark one ...

The concept of CSS inheritance within div elements

I've been researching extensively about the concept of CSS inheritance, but I have come across a puzzling question that remains unanswered. Consider the code snippet below: <!DOCTYPE HTML> <html> <head> <style type="text/css"> ...

Embed a YouTube video within the product image gallery

Having trouble incorporating a YouTube video into my Product Image Gallery. Currently, the main product photo is a large image with thumbnails that change it. You can see an example on my website here. Whenever I attempt to add a video using the code below ...

What is the best way to implement jQuery on my website?

Instead of copying all the example code here, you can check out the jQuery demo page: Demo Page I would like to integrate the Latest News example with scrolling text in red from the demo page into my website. The demo page also provides links to the sour ...

Upon page load, a dazzling SVG file will flicker before being adorned with CSS styles

I'm experiencing an issue with an SVG arrow icon on my webpage that flashes quickly across the entire screen upon page load before settling into its proper size and placement. I've tried using CSS to initially hide the icon and then reveal it aft ...

Is it feasible to send a GET form to two separate views using two buttons?

On one view, I have a form that functions perfectly. http://myurl.com/myapp/filter_objects/?risk__worktask=1&craft=3 In another view, I need to export the filtered list to a PDF. Currently, I store the results in session and access the list from ther ...

Problem encountered during the transfer of JSON data from PHP to JavaScript

Currently, I am working on a PHP file that extracts data from a database to display it on a chart using the Chart.js library. The chart is functioning properly, but I am facing an issue where I need to use the json_encode() function to pass the array value ...

Encountering an issue when running the command "ng new my-app" after updating the @angular/cli package

npm version 7.5.4 has been detected, but the Angular CLI currently requires npm version 6 to function properly due to ongoing issues. To proceed, please install a compatible version by running this command: npm install --global npm@6. For more information ...

The Jqueryui image link is not displaying the image despite no error being reported

Can anyone help me figure out what I'm missing? I'm currently working with ASP.NET MVC 5 and have downloaded the JqueryUI combined via Nuget package. Despite no error references for css/js files, the close button is still not showing in the ima ...

Bring back object categories when pressing the previous button on Firefox

When working with a form, I start off with an input element that has the "unfilled" class. As the user fills out the form, I use dynamic code to remove this class. After the form is submitted, there is a redirect to another page. If I click the "back" ...

New feature: Material UI Chip Input with floating input label

I installed material-ui-chip-input to implement tags in an input field. I wanted a label alongside it, so I utilized the default Material UI label for consistency with other inputs. However, the input doesn't shrink as expected when clicked on by the ...

Avoiding redirection in Django template form

Currently, I am facing a challenge with my application that involves rendering a Django Template model form where images are referenced from another model. To manage the addition and deletion of images for this other model, I have implemented a button wit ...

Is it possible to manipulate elements within an overflow container using JavaScript/jQuery when using the HTML style "overflow:hidden"?

My <div> has a styling of style="overflow:hidden" and the size of the <body> is fixed, intended as a multi-screen display without a user interface. Is there a method to access these "invisible" elements to identify the first one that exceeds t ...

CSS rule: The behavior of my specified property is not being implemented

I have inserted an image directly into my HTML code, which serves as a small profile picture. I am attempting to position this image in the top right corner of my website, but no matter what CSS property I apply, the image refuses to budge. body { fon ...

Retrieve the next element in android studio that shares the same class name as jsoup

i am trying to access the next element with the same class name in HTML. The HTML tag structure looks like this: HTML: <section class="post"> <img class="pecintakomik" src="/images/top/op.jpg" alt="pecintakomik.com" /> <div class=" ...

Flickity remains in plain sight on desktop devices

I am trying to hide the flickity slider on desktop and larger devices. I have followed the instructions in the documentation, but for some reason, it's not working as expected. Here is how the div looks: <div class="w-full flex pl-4 pb-16 overflo ...

Transforming data from a particular csv file and embedding it into an html document

I am currently working on a feature that allows users to select a specific CSV file and display it as an HTML table on the webpage with the click of a button. The process involves: Selecting the desired file from a dropdown menu to determine the CSV fi ...