How can I eliminate the padding from an image button in Bootstrap 5?

I am facing an issue with removing padding from a button that has an image inside it. I have tried using style="padding: 0px !important" and the p-0 class, but it doesn't seem to work. Switching the <button> to <a> removes the padding, but then I lose the click effect. Any solutions or suggestions?

https://i.sstatic.net/wbxwJ.jpg

https://i.sstatic.net/18B32.jpg

This is my HTML Navbar:

<nav class="d-flex icon_ah navbar sticky-top navbar-dark bg-dark navbar-expand-lg p-0">
    <div>
        <form action="#">
            <button type="submit" class="navbar-toggler p-0 m-2 border-0">
                <span class="bi bi-house-fill"></span>
            </button>
        </form>
    </div>
    <div>
        <form class="btn-group">
            <button class="navbar-toggler p-0 m-2 border-0" id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-expanded="false" data-bs-display="static">
                <span class="bi bi-plus-circle"></span>
            </button>
            <ul class="dropdown-menu bg-dark d-lg-none" aria-labelledby="dropdownMenuButton1">
                <?php for ($i = 0; $i < count($item_ah); $i++) { ?>
                    <li><a class="dropdown-item" href="<?= $item_ah[$i][1]; ?>"><?= $item_ah[$i][0]; ?></a></li>
                <?php } ?>
            </ul>
        </form>
    </div>
    <div class="ms-auto">
        <form class="btn-group">
            <button class="navbar-toggler p-0 m-2 border-0" id="dropdownMenuButton2" data-bs-toggle="dropdown" aria-expanded="false" data-bs-display="static">
                <img class="rounded" style="height:29.33px;" src="\img\system\user.png" alt="user-glories">
            </button>
        </form>
    </div>
    <div class="collapse navbar-collapse" id="navbarNavDropdown">
        <ul class="navbar-nav">
            <li class="nav-item icon_ahm">
                <a class="nav-link" href="<?= base_url('#'); ?>">
                    <b class="bi bi-house-fill"></b> Dashboard</a>
            </li>
            <li class="nav-item dropdown icon_ahm">
                <a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                    <b class="bi bi-plus-circle-fill"></b> New
                </a>
                <ul class="dropdown-menu bg-dark" aria-labelledby="navbarDropdownMenuLink">
                    <?php for ($i = 0; $i < count($item_ah); $i++) { ?>
                        <li><a class="dropdown-item" href="<?= $item_ah[$i][1]; ?>"><?= $item_ah[$i][0]; ?></a></li>
                    <?php } ?>
                </ul>
            </li>
        </ul>
    </div>
</nav>

This is my CSS:

.sampul {
  width: 70px;
}

.table > tbody > tr > * {
  vertical-align: middle;
}

.icon_ah > div > button,
.icon_ah > div > form > button {
  font-size: 29.33px;
}

.icon_ahm > ul > li > a,
.icon_ahm {
  font-size: 13px;
}

.dropdown-item {
  color: #b4b9be;
}

.dropdown-item:hover {
  color: rgb(85, 85, 85);
  background-color: rgba(255, 255, 255, 0.856);
}

.dropdown-item:active {
  color: rgb(0, 0, 0);
  background-color: rgba(255, 255, 255, 0.363);
}

Answer №1

Have you attempted adjusting the box-sizing property to content-box?

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

I am experiencing issues with my INSERT INTO statement

I've been working on creating a news system that allows users to fill out a form to post an article. However, despite multiple attempts and methods, my INSERT INTO query doesn't seem to be functioning properly. I have two separate files for this ...

What is the best way to display a child div without impacting the position of other elements within the same parent container?

As I work with a div html tag within a login form, encountering an error inside this form has presented a challenging issue. The error div sits at the top of its parent div, and ideally, upon activation, should remain within the form div without disrupting ...

Step-by-step guide on positioning mid and bottom text using Bootstrap grid system

After searching and trying various solutions, I am still unable to get the desired output. My goal is to use grids in Bootstrap to set the footer layout with the class "link-footer" positioned at the middle height of the div and the class "footer-copyright ...

Prevent the border from shrinking upon being clicked

I'm currently working on customizing an accordion using jQuery for the animation effects. However, I am facing an issue where clicking on the accordion header causes the border around the plus sign to shrink in size as well. My goal is to only have th ...

Setting the CSS position to fixed for a dynamically generated canvas using JavaScript

My goal is to fix the position style of the canvas using JavaScript in order to eliminate scroll bars. Interestingly, I can easily change the style using Chrome Inspector with no issues, but when it comes to implementing it through JS, I face difficulties. ...

Random variable without repetition in SASS

I have a unique project where I am tasked with incorporating a list of 5 specific colors into 10 different div elements. The challenge is that each color must be used twice and in a completely random order without any repetition of colors. Although utilizi ...

What is the method for indicating the bootstrap version in the Laravel/ui package?

I am currently incorporating Bootstrap into my Laravel project with the help of the laravel/ui package. If you are interested, you can check out the laravel/ui GitHub repository at https://github.com/laravel/ui. I am following the setup instructions by ru ...

The correct rendering of background image paths is not functioning properly

Currently, I am utilizing Django Compress to streamline the process of using fewer files in their original format, rather than converting them to CSS files. This method has been successful except for a minor issue with translating the paths for background ...

The poker table designed with CSS does not resize effectively when displayed in smaller dimensions

I have put together a CSS poker table design that I am quite happy with at the moment: https://jsfiddle.net/78fcs01m/3/ CSS: .poker-container { display: grid; width: 100vw; height: 100vh; .poker-table { justify-self: cent ...

Updating the chosen value in an HTML select menu dynamically using PHP

I understand that there are existing examples discussing how to dynamically set the selected tag in an HTML option tag. However, I am encountering a complex issue involving break statements and quotations while trying to accomplish this. In my code: whil ...

Div with wide width and captivating perspective

Recently, I've been experimenting with perspective and 3D transformations, and I've realized why my div isn't displaying at full width despite setting it in the CSS. However, I'm interested in creating a responsive layout where the div ...

Utilizing transitions to control the visibility of div elements

This is what I have achieved so far: function getOffsetRect(elem) { var box = elem.getBoundingClientRect() var body = document.body var docElem = document.documentElement var scrollTop = window.pageYOffset || docElem.scrollTop || body.sc ...

Determine the width of invisible images using JavaScript/jQuery

Please take a look at the jsFiddle Every time I run it, I am trying to retrieve the width of the images, but the values I get are as follows (check in the JS console) 400 0 575 533 0 ... Some values are zero, and I can't figure out why. It seem ...

Tips on creating Twitter Bootstrap tooltips with multiple lines:

I have been using the function below to generate text for Bootstrap's tooltip plugin. Why is it that multiline tooltips only work with <br> and not \n? I would prefer to avoid having any HTML in my links' title attributes. Current Sol ...

Is it possible to extract tooltip text from a website using Python and Selenium, specifically when the text is generated by JavaScript?

Can anyone help me retrieve the tooltip text that appears when I hover over the time indicating how long ago a game was played? You can find my summoner profile here. I have noticed that the tooltip text is not visible in the HTML code and suspect it may ...

What is the method for compressing text in CSS?

I'm curious about how to condense my text so it doesn't extend beyond the page. Any ideas on how to achieve this? Issue: Solution: .Subheading{ text-align:center; font-family: 'Mukta', sans-serif; margin-top:70px; m ...

When is the appropriate time to utilize the style attribute in CSS?

Hey there, I'm in the process of building a website from scratch and I've hit a snag. I understand that using the style tag isn't ideal, but would it be acceptable in this scenario? Is there a more efficient approach? Let's consider t ...

Integrating CSS with Material-UI in a React project: A step-by-step guide

I am currently developing a project using React (along with TypeScript) and the Material-UI library. One of my requirements is to implement an animated submit button, while replacing the default one provided by the library. After some research, I came acr ...

What exactly is the purpose of the double ampersand selector, '&&', when it comes to overriding the root class with makeStyles within Material-UI React?

I recently started using Material-UI and encountered an issue where I couldn't override the root class for Avatar, specifically MuiAvatar-root. Material-Ui Version: 4.11.3 Despite following examples provided by material-ui's documentation here, ...

Is CodeMirror's PHP mode failing to function properly?

There seems to be an issue with displaying the highlighted text, and I'm not sure why. Links: <link rel=stylesheet href="http://codemirror.net/mode/php/../../doc/docs.css"> <link rel="stylesheet" href="http://codemirror.net/mode/php/../../l ...