The button I've designed can't be clicked directly on the text or icon, but rather around them

I'm facing an issue with a button that has an icon and text below it. The clickable area is only around the icon and text, not on them.

https://i.sstatic.net/55FWF.png

scss file

.navbar {
  background-color: #292929;
 height: 70px;
}

.button {
  display: flex;
  flex-direction: column;
  background-color: transparent !important;
  color: white !important;
  margin-left: 100px;
  margin-top: 5px;
  width: 60px;
  height: 60px;
  padding: 10px;  
}

.bx {
  margin-left: 15px;
  font-size: 30px;
}

.icon {
  flex: 1;
}

.text {
  text-align: center;
  color: white;
  font-size: 12px;
  margin-left: 4px;
}

/* Add hover effect to the button */
.button:hover .text, 
.button:hover .bx {
  color: red;
}

html

    <nav class="navbar" role="navigation" aria-label="main navigation">
      <div class="navbar-start">
        <!-- Button on the left side -->
        <button class="button" (click)="logInfo()">
          <span class="icon">
            <i class='bx bx-file-find'></i>
          </span>
          <a href="#" class="text">Scan</a>
        </button>
      </div>
      <div class="navbar-end">
        <!-- Text on the far right side -->
        <div class="navbar-item is-size-5 has-text-white">test</div>
        <img src="assets/favicon.ico" />
      </div>
    </nav>

The solutions I tried so far include adding padding and margin, setting pointer-events to none, changing the display to block which caused the text to move, using a different icon, and applying z-index:999 but none of these fixed the issue.

Answer №1

It is important to note that interactive content should not be placed inside a button element. This means that the <a> tag should not be included within your button, as it can cause issues on your webpage.
To resolve this issue, simply remove the anchor tag from inside the button and it should function properly.
If you would like your button to scroll to the top of the page, you can include the code window.scrollTo(0, 0) in the logInfo function that is triggered when the button is clicked.

<button class="button" (click)="logInfo()">
  <span class="icon">
    <i class='bx bx-file-find'></i>
  </span>
  <span class="text">Scan</span>
</button>

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

Can you explain the significance of the 'project' within the parserOptions in the .eslintrc.js file?

Initially, I struggle with speaking English. Apologies for the inconvenience :( Currently, I am using ESLint in Visual Studio Code and delving into studying Nest.js. I find it difficult to grasp the 'project' setting within the parserOptions sec ...

Can you fill two dropdown menus with an array of choices?

I'm encountering an issue with using an array to populate two different select boxes. The first select box gets populated correctly, but when trying to add the same list to the second select box, it clears the first one and automatically selects the l ...

Utilizing Angular's ngShow and ngHide directives to hide spinner when no data is retrieved

I'm having an issue with the HTML code below. It currently displays a spinner until a list of tags is loaded for an application. However, the spinner continues even if no events exist. I want to make the spinner disappear and show either a blank inpu ...

Searching and retrieving database results from inside a Bootstrap modal

Can I execute a MySQL database query from within a Bootstrap modal, based on user selection, and display the results in the same modal without it closing? Below is an example of the two drop-down menus in my modal. <div class="tab-pane" id="relevance"& ...

Reading a single line of text synchronously in Node JS

I have a scenario where I need to process a file named data.txt that contains thousands of lines. My objective is to read each line, extract specific data, and store it in an array. To achieve this, I am using the readline and fs.createReadStream functions ...

The process of setting up React in the terminal becomes tricky when the VS code editor is directing to a non-existent path

Issue with VS Code editor not recognizing existing path Recently attempted to install React using the npx command in the terminal, following steps from various tutorials on YouTube. Despite trying all suggested methods, the installation didn't succee ...

Encountered an issue while attempting to integrate Nebular into my Angular application

As a newcomer to Angular, I decided to try installing Nebular using the command ng add @nebular/theme. However, I encountered an error in the process. Upon entering the command into my terminal, the following error message appeared: ? Which Nebular theme ...

Difficulties encountered when trying to store a checkbox array data into a database

Within my application, I am faced with the task of extracting checkbox items from a list and storing them in my database. Currently, I am assembling these items into an array by iterating through the options, adding a checkbox before each one, and assignin ...

Is there a way to disable tslint warnings for npm linked packages?

Currently, I am in the process of developing a set of Angular/TypeScript components within an application that utilizes this package. To facilitate the sharing of these components, I have utilized npm link. However, upon building the project, I encountered ...

Dealing with circular dependencies in NestJS by using ForwardRef

Hey everyone, I've been running into a circular dependency issue with NestJS. I tried using the forwardref method, but it hasn't resolved the problem for me. // AuthModule @Module({ imports: [ forwardRef(() => UserModule), JwtModule ...

The Node.js application successfully operates on a local environment, however encounters issues when attempting to run on docker resulting in an error message stating "sh

Despite successfully building the docker image, I am facing difficulties getting the container to run. Below is the content of the package.json file: { "name": "linked-versions-viewer", "version": "1.0.0", &quo ...

Preserve the formatting of the text within the list item

I'm currently working on a website where I have a ul element set up. Each list item contains text, but when I zoom in and out of the page, the text overflows the box. Is there a way to prevent the text from overflowing the list item? HTML <div ...

How can I retrieve the ClientID of a div element within an ASPX page using JavaScript?

Is there a way to retrieve the client id from a contentplaceholder in an aspx page without involving the master page? I understand that a div is not a control, but I am curious if there is a workaround. (Please note that the code displayed is not within th ...

Reordering divs in one column with CSS Flexbox to transition to a two-column layout upon resizing the screen

Exploring the world of Flexbox, I'm not entirely convinced it's the right solution for my layout challenges. Here's what I have in mind: In a 940px wide space, I need to create three columns with fixed widths of 300px each. However, on medi ...

I encountered difficulties connecting mongoose to my local MongoDB server

Hello Everyone! Currently, I am in the process of linking my node.js project to mongodb. Initially, everything worked smoothly when I used mongodb atlas. However, when I attempted to connect it using mongodb compass, I faced some issues and nothing seemed ...

Pictures do not adhere to the maximum width set on their parent elements

When the max-width CSS style is set on the body tag and an image within the body surpasses this maximum width, the image does not adhere to the set limit. Instead of resizing, it simply overflows. Why does this happen? So, what is the solution to this pro ...

``To utilize the ng-class variable within a controller, one can simply assign the desired

How can I change the color of a div to green using AngularJs when a file is selected? html <div class="text-arrow" ng-class="{activeBackground:applyActive}">File Selection<span class="arrow-div"></span></div> css .activeBack ...

Issue with :hover pseudo-class in IE8

If you're unsure about my explanation, check out the video for a visual demonstration. Pay close attention to the cursor movements while I attempt to optimize my website for IE8. Hopefully there is a solution to this issue. Thank you in advance! http ...

Disabling vertical scrollbar in textarea within Bootstrap modal using CSS, jQuery, and C# in .NET MVC framework

I am passing data to the Bootstrap modal using jQuery from my database. The form values can change from a single row to multiple rows. I do not want a scrollbar, but instead I want the textarea element to automatically adjust its height to fit the content. ...

What is the method for choosing outerHTML using Simple HTML DOM Parser?

Check out this code snippet: include('simple_html_dom.php'); // Creating a DOM from the specified URL $page = "http://indonesiax.co.id"; $html = new simple_html_dom(); $html->load_file($page); // Locating all images in the HTML $value = $htm ...