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

Guide to positioning an image absolutely within a div

I am struggling to position a small close image within a div without success. The goal is for the image to always appear on the left side of the div, regardless of the content. The content consists of a text label with a maximum length of 8 characters. Iss ...

List of items displayed in alphabetical order using the ng-repeat directive:-

I'm working with an ng-repeat block in the code snippet below. My goal is to have the placeholder [[THE ALPHABET]] render as a, b, c, d representing bullets for the list in their respective order. There will always be 4 values present. What would be t ...

When jQuery fails to detach() due to the presence of an input tag

I have a situation where I am trying to rearrange elements within a table. Everything works fine, until I introduce a tag, which triggers this error message:</p> <pre><code>Error: this.visualElement is undefined Source File: http://192. ...

How can I animate scrolling up or down using jQuery and CSS?

I have a a element that triggers an action when clicked: <a href="#" class="hel" onclick="YPCP1_();">Scroll down</a> Also, function YPCP_(){ var scroll = $(window).scrollTop(); window.scrollTo(0, 600); } The function successfully sc ...

Issue with Bootstrap v3.3.7 panel not collapsing as expected following height adjustment

Utilizing bootstrap 3.3.7 panels, I encountered an issue when trying to slide up the panel using the icon. The panel would not hide properly once the panel height was set, resulting in only the panel content body sliding up. Here is an example: $(&apo ...

vue form is returning empty objects rather than the actual input data

I am attempting to transfer data from my component to a view in order for the view to save the data in a JSON file. I have verified that the view is functioning correctly as I attempted to log the data in the component and found it to be empty, and the r ...

Creating a Shopping Cart using Laravel and Angular

My current application features a shopping cart that works well for me, but my colleague finds it to be too "slow". I have been brainstorming ways to improve its efficiency and speed. This is the process of how my page currently loads: The Product/Ticke ...

Proper Sequence of Bootstrap Header Configuration

I'm working on creating a header/navbar using bootstrap, but I'm unsure about the correct order and method to achieve this. This is how I want it to look: And when collapsed: Should everything be contained within the NAV tag? I have a header ...

Utilizing HTML5 data attributes to store intricate JSON objects and manipulate them using JavaScript

Recently, I encountered a unique challenge that I set for myself... I am currently in the process of developing an advanced ajax content loader plugin that comes with an array of options and callbacks. In order to streamline the initialization process and ...

ng-click-outside event triggers when clicking outside, including within child elements

I am looking to trigger a specific action when I click outside of the container. To achieve this, I have utilized the ng-click-outside directive which works well in most cases. However, there is one scenario where an issue arises. Inside the container, the ...

What is the best way to integrate PHP code within CSS?

I'm working on a script that requires me to add PHP code within a CSS stylesheet. However, when I attempt to do so, nothing seems to happen! Is it even possible to include PHP code in a CSS file? ...

Sorting data based on column names

New to Angular and looking to create a table displaying news items in different categories. Each news item will have a category, heading, subheading, and introduction, with one column for each category: US International Head1 Head1 Sub1 Sub1 ...

Expand Elements to occupy entire width

My CSS skills are still in the early stages. I haven't delved too deeply into it. I have a query regarding how to achieve full width for an element. I've included my code below, but the basic approach I tried using 'width: 100%' didn&a ...

Utilize Material icons in CSS for a list in Angular 9

My task involves altering the HTML provided by a content management system for one of our applications. Specifically, I need to replace all "ul"s with <mat-icon>check_circle_outline</mat-icon> instead of the default "." The challenge lies in t ...

Using PHP header function to redirect to a specific form on an HTML page: A step-by-step guide

I have a dilemma in my web project. In the index.php file, there are two forms that utilize transitions to switch between pages (Login and Register). When attempting to register a new user in the backend, I check if the user already exists. If they do exis ...

AngularJS: Render the initial element of the result set array

Currently, I have a form that consists of two dynamic dropdowns - one for selecting the location and the other for choosing the branch. When a location is selected, the corresponding branches for that location will be automatically displayed in the Branch ...

Unable to change the variable for the quiz

Currently, I am in the process of developing a quiz app and I am facing an issue with my correct variable not updating. Whenever I trigger the function correctTest() by clicking on the radio button that corresponds to the correct answer, it does get execut ...

What's the best way to customize the dropdown icon in Bootstrap 5?

Is there a way to customize the default icon in the Bootstrap 5 dropdown menu and replace it with a Font Awesome character? I have gone through the documentation, but it didn't provide any helpful information. I also attempted to override the CSS styl ...

Assigning a class to an li element once the page has finished loading

I am facing an issue with my navigation bar where the links are dynamically loaded from a database using a foreach loop. Although the nav bar is static, I want to apply an 'Active' class to the link when it is currently active. Despite trying to ...

Including hyperlink tags within a CSS file

Can you create internal links within a CSS file, like inserting a table of contents at the top where you can click on an item and immediately jump to that section in the CSS file similar to an anchor tag? This feature would be extremely handy for long CSS ...