Dealing with ng-repeat and button alignment across Chrome, Edge, and Firefox

Can someone help me understand this strange behavior I am experiencing across all browsers?

<div style="margin-top:5px">
    <button translate="clear" ng-click="xyz.clear()" class="btn btn-default"></button>                
    <button ng-repeat="operation in xyz.operations" class="btn btn-default">{{operation.name}}</button>
</div>

https://i.stack.imgur.com/vVnbB.png

I have a button and another button with an ng-repeat inside a div. The spacing between the first 'static' button and the first button from ng-repeat is unexpected. This spacing persists consistently across all tested browsers, leading me to believe that it may be related to Angular's ng-repeat.

Inspecting the elements in Chrome Dev-Tools shows:

https://i.stack.imgur.com/aAVTq.png

No CSS selectors seem to affect the spacing between the buttons. Even when rearranging them in the DOM using Dev-Tools, the odd behavior remains:

https://i.stack.imgur.com/JOo9L.png

The computed box for the element is identical for all buttons as shown here: https://i.stack.imgur.com/Q0ijh.png

Answer №1

This issue is not related to the functionality of ng-repeat. The default display property for the button element is inline-block (MDN)

To eliminate the space between the buttons, you can apply a left margin of -5px.

Here is a helpful CSS-Tricks article on this topic. It includes a demo showcasing the problem and its solution.

#fix button{
  display: inline;
  margin-right: -5px;
}
<div id="problem">
  <button>clear</button>
  <button>clear</button>
  <button>clear</button>
</div>

<div id="fix">
  <button>clear</button>
  <button>clear</button>
  <button>clear</button>
</div>

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 activate an onchange function when using a <select> element?

Is there a way to automatically trigger a JavaScript function without the need for user input, while still having a default option selected? <select class="custom-select" name="" id="timer1numbers" onchange="getSelecte ...

Splitting JavaScript files in the "dist" folder based on their source folders can be achieved in Angular by using G

I’m currently utilizing gulp-angular for my project, but I’m facing a challenge due to my limited experience with node and gulp when it comes to modifying the default scripts task. My goal is to generate an optimized JS file for each folder within my ...

Type in "Date" and select a date using your mobile device

Hey, does anyone know a good solution for adding placeholder text to an input with type="date"? I'm looking for a way to utilize the phone's built-in date selection feature on a website, rather than having users manually enter dates using the ke ...

Various instances of controllers in Angular.js and JavaScript

I'm facing a challenge with a view that has two identical parts but different content. I want to find a way to use one controller and one view for both the left and right parts. Here's what I currently have in my HTML: <div class="board_bod ...

Preserving distance between absolute elements

I'm facing an issue with my menu animation using jQuery. In order to achieve the desired effect, I am forced to use position: absolute. My challenge is maintaining consistent spacing between each text string, especially since they vary in width. Unfor ...

The d3 drag functionality is only active when the axis ticks are selected

Currently, I am developing a unique package that combines Angular and D3 (v3) and my main focus is on integrating D3's dragging feature into the package. Although I am very close to achieving success, there is a minor bug that I need to address. When ...

How can I convert the left links in my navigation bar to a CSS drop-down menu to make it more responsive on small screens?

Here is the structure of my HTML (at the top): <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></s ...

Can anyone help me with displaying auto complete HTML files in VScode?

As a Korean, please excuse my lack of proficiency in English. This image displays the autocomplete feature for HTML files in IntelliJ. This particular file was generated by Spring Boot (start.spring.io). How can I achieve the same in VSCode? ...

Using Selenium with C# to input text into an HTML <input> tag is not functioning properly

I need help figuring out how to fill in an input field on a website using HTML. Here is what the section of the website () looks like: <div class="flex-item-fluid"> <input autocomplete="username" autocapitalize="off" ...

Assess transcluded content prior to template compilation in an AngularJS directive

I am currently developing a custom "collapseText" directive using AngularJS. The purpose of this directive is to display a specified maximum number of characters and provide a "Read More" option to expand the text if it exceeds the limit. My goal is for t ...

Protractor and Jasmine fail to fulfill the promise of retrieving a webpage title

I am facing an issue with my protractor/jasmine test code where it only prints out 1 and 2, then hangs and times out. It seems like there might be a problem with the click() action on the button element or the promise on the getTitle method of the browser ...

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 ...

The Scottish flag isn't displaying on my website, but all other Emoji 5 symbols are working perfectly

When I build my website with PHP, I include header('Content-Type:text/html; charset=utf-8'); at the start. Interestingly, the Scottish flag emoji ...

Trouble arises with AJAX due to DOM traversal errors

I am trying to set up a system for liking and disliking with a counter. However, I am facing issues with my AJAX call, specifically when attempting to change the HTML of selected elements in the view after sending values to the DB. The element in question ...

What is the best way to link multiple select tags in an HTML document?

I am working with a data grid that contains student information such as Name, Class, and Score. Each row has a checkbox for selection. The requirement is that when the user selects one or more rows and clicks on the "show information" Button, a new windo ...

Concealing two div elements based on string content

I am working on a unique Wordpress blog post layout that showcases personnel profile cards, displaying 12 individuals at a time. Depending on whether or not a person has a Twitter handle entered in the backend, certain elements should either be shown or hi ...

How can I stop a hyperlink from activating Jquery?

A script was created to highlight any <TR> element when a user clicks on it, and it is functioning correctly. <script> $(document).ready(function () { $(document).on('click', 'tbody tr', function (e) { ...

What is the process for setting a cookie that allows for reading from the same domain with a different port?

After setting my cookie in C# code with Request.Cookie["NTLogin"].Value="XYZ", I encountered an issue when attempting to read this cookie from a new application built in Angular JS. To access the cookie, I used $cookies.get('UserNTLogin'). The p ...

Place a <ul> list in the center

I've hit a roadblock trying to find a solution for this issue. Nothing I've attempted so far has proven successful. I'm hopeful that someone could lend me a hand. The challenge at hand involves centering a standard <ul> list on the pa ...

AngularJS ng-repeat not displaying bold fonts in HTML output

Despite successfully outputting HTML for the most part, some of the styling seems to be getting stripped out. As you can see in the images below, the /ul/ is properly rendering the /li/ items within an ng-repeat, but the BOLD font is not displaying correct ...