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's the name of the auto-triggered dropdown menu feature?

Visit Amazon's official website Description: Within the 'Shop by Department' section- A drop-down menu that remains visible without requiring you to hover over it. However, when the browser is in a non-full-screen mode, the menu disappears ...

Stop Element-UI from automatically applying the list-item style to li elements

I have a list of data elements that I am rendering in the following way: <ul> <li v-for="el in elements"> {{el.data}} </li> </ul> Here's how I style it in my .css file: ul { list-style-type: none; padd ...

Dynamic image swapping using JSON key in Angular

Trying to display different icons based on a property that contains specific words. If the property includes "Health Care" or "Health Care .....", I want to show one image, otherwise another. I've tried using ng-show but my syntax seems off. Any sugge ...

Unlocking the potential of the :not selector when combined with the :nth-of-type selector

My current project involves styling a table. I am looking to apply a specific background color to each odd row, excluding the first row which contains headers. I attempted the following code without success: .new-items-table tr:nth-of-type(odd):not(.new- ...

Customizing Styles in Material UI with React

I am facing an issue with customizing the styles in my Material UI theme in React. Specifically, I am trying to modify the border of the columnsContainer but it doesn't seem to work, only the root style is having an effect. Take a look at this Codesa ...

Tips for scrolling a div that has too much content within a webpage

Is there a method to manipulate the scrollbar within a div on a webpage? Specifically, I am attempting to automate scrolling up and down on an Instagram post like . However, since the scrollbar may be hidden using CSS properties, detecting it can be challe ...

A triangular-shaped div positioned at the bottom with a captivating background image

Is there a way to create a div with a unique twist - a triangle shape at the bottom? I've been attempting to add a background image within the triangle using a pseudo element (:after), but so far, it hasn't been successful. #homebg:after{ co ...

Mastering the Bootstrap 'Thumbnail Grid System'

I'm having trouble aligning all the images in my design. Even though I'm using Bootstrap's column classes (class="col-sm-4 col-md-3"), they are not displaying equally. Here is a screen recording showcasing the issue: Click here to see the s ...

Issue with ASP.NET Base64 image source rendering incorrectly

After retrieving a Base64 string from Azure active directory using a Lambda function, which represents a user's profile picture, I am facing issues displaying it on an ASP.NET page. Below is the code snippet in ASP.NET (The referenced HTML object is ...

What is the answer to this issue where the entity name is required to directly come after the "&" in the entity reference?

Whenever I insert the code into my Blogger platform, an error pops up stating: The entity name must directly follow the '&' in the entity reference Here is the code: <script> if (typeof bc_blocks == "undefined" && wind ...

Enhance your CSS link in Yii framework 2.0 by incorporating media printing capabilities

While working on Yii framework 2.0, I typically include a CSS file by adding the following code snippet to assets/AppAsset.php: public $css = [ 'css/style.css', ]; Upon inspecting the element in the web browser, I notice the following code ...

Ensure that the "select" dropdown menu remains a constant size

One section of my Android app, powered by JQuery Mobile, displays a table with a combobox. The issue arises when selecting the option with a very long text, causing the combobox to expand and show half of the table off-screen. My goal is to set the combob ...

Can the direction of a splide slider be altered in a responsive design?

Is there a way to change the direction of a Splide slider in a responsive design? I'm running into issues when attempting to adjust the thumbnail slider's direction in responsive mode. var secondarySlider = new Splide("#splidev2", { ...

The Less compiler (lessc) encounters an issue on a fresh operating system. ([TypeError: undefined is not a function])

After setting up my new development environment on Windows 10, I encountered an issue with less. Following the instructions on lesscss.org, I installed less using: npm install -g less The installation process completed without any errors. However, when ...

Guide on creating line breaks within a list in a Python email

I'm having trouble querying a list from my Flask database and then sending it out as an HTML email. The issue is that I can't seem to break the list items into different lines. For example, instead of: a b c I currently get 'abc' i ...

Dash that serves as a barrier between two words to avoid them from breaking onto

Is there a way to keep a dash ( - ) from breaking a word when it is at the end of a line? Similar to how &nbsp; prevents a line break between two words. The issue I am facing currently is with a dynamic blog post that includes the word X-Ray. Unfortun ...

What is the correct way to adjust the style.top attribute of an element using JavaScript?

In order to correct a JavaScript source code, I need to adjust the style.top property of a div element based on an integer parameter from a function called index. Here is the current implementation: div.style.top = (index * 22 + 2)+"px"; However, for lar ...

Effortlessly adjust item width in CSS Grid

I am currently utilizing CSS Grid to showcase various tags. If a tag happens to be quite large, with a width exceeding 150px, I would ideally like that specific item to expand across multiple columns as necessary. For instance, in the visual representation ...

Update the central information while keeping the entire webpage intact

Hey there, I could really use some assistance! I'm working on a software documentation website that is similar to the mongodb documentation page. It has a header, sidebar (navbar menu), and main content area. Within the sidebar navbar menu, I have dr ...

Problems arising from positioning elements with CSS and organizing list items

I've been working on creating a navigation sidebar using Angular and Bootstrap, but I'm having trouble getting my navigation items to display correctly. APP Component HTML <div class="container-fluid"> <div class="row" id="header"&g ...