Position two buttons on the right side of the text

Is there a way to align two buttons on the far right side of a block of text? I want all the content to be in line, with the text on the left and the buttons on the right. While I've found solutions for aligning one button, I'm struggling to get two buttons aligned properly.

In my code, I iterate over the 'weaknesses' array and display each weakness along with update and delete buttons.

I attempted to use margin-left, but due to varying lengths of weaknesses, the buttons didn't align correctly.

I also looked at suggestions from this post: Place a button right aligned, but couldn't achieve the desired result.

If anyone could offer guidance or assistance, it would be greatly appreciated.

HTML

<div *ngFor="let weakness of weaknesses | async">
    <div class="flex-box">
        <p>{{ weakness }}</p>
        <a class="btn btn-light btn-sm pull-right" href="#">Update</a>
        <button type="button" class="btn btn-danger btn-sm">Delete</button>
    </div>
</div>

Answer №1

Give this a shot:

#btnHolder {
  position:fixed;
  top:10px;
  right:10px;
  
}
<p>Insert text here</p>
<div id="btnHolder">
    <button>Submit</button>
    <button>Remove</button>
</div>

I'm not sure why it was so challenging. It seemed like fixing this issue should have been simpler.

Answer №2

One effective method involves using auto margin in combination with flexbox

nav {
  display: flex;
  align-items: center;
}

nav button:first-of-type {
  /* The key concept is setting margin-left to auto */
  margin: 0 10px 0 auto
}
<nav>
  <span>Text</span>
  <button>Button 1</button>
  <button>Button 2</button>
</nav>

Answer №3

Here is a recommended approach:

 .flex-box {
      display: flex;
      align-items: center;
      justify-content: start;
  }

 #buttons{
      margin-left: 10px;
  }
  <div class="flex-box">
  <p>Content Goes Here</p>
  <div id="buttons">
   <a>Update</a>
   <button>Delete</button>
 </div>
</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

Error: Attempted to export 'e', however it was not defined in the module (located at vite.js?v=d59cec13:236:3) - occurring in the three.js/vite combination

After dabbling in javascript, I decided to explore three.js and found it quite intriguing. However, after hours of setting everything up, I encountered a roadblock. When I attempted to create geometry and render it, the code stopped working. Upon investiga ...

The file size of clr-ui-dark.min.css seems unexpectedly large, despite attempts to optimize the bundles

Has anyone else noticed a similar issue in their projects, or could it be that I made a mistake? It appears to me that the dark styling comprises roughly 33% (according to webpack-bundle-analyzer) of my app's total size. https://i.sstatic.net/fLduq.j ...

Using Bootstrap: adjusting the height of input-group and select elements

How come the select element within an input-group doesn't render similarly to the input element? I would like the height of the select element to be relative to the input-group. <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css ...

What is Microsoft's equivalent to an embedded Java web applet?

Is there a Microsoft alternative to embedded Java web applets? Can you provide an example from the internet? Furthermore, why is ajax prevalent in dynamic web development compared to embedded applications? ...

Occupying room while using display: none in <td>

As a newcomer to media queries and .net, I find myself struggling with the code below. At max-width 775px, my goal is to have the first td disappear completely and be replaced by the second td. However, it seems that while the first td becomes 'invisi ...

What is the more effective choice for Automation Testing: Static or Dynamic dropdown menu options?

Currently facing an issue with dropdown selections while conducting automated testing. Selenium's Select(); method has been reliable when running tests in multiple cycles and choosing different options each time. The challenge arises when the dropdow ...

Tips on extracting all selectable text from a webpage using Python

Currently, I am tackling a web scraping project that involves extracting all copyable text from a visually displayed web page. I experimented with various techniques such as parsing the HTML code based on keywords, but unfortunately, I encountered roadblo ...

Issue encountered when trying to retrieve the property of an object within an array in an Angular application

Having an issue with comparing path properties in Chrome https://i.sstatic.net/o3MnP.png Chrome debug shows different content for path properties compared to Angular https://i.sstatic.net/b0FrD.png Angular throws error: 'Property 'path' ...

Image container unable to resize to fit within a CSS grid cell

I'm currently working on organizing a CSS grid for my images on a tribute page project from free code camp. I was able to set up the grid as intended, but I am facing some difficulties in making the images fit perfectly within each cell. Some images a ...

Can you explain how to set a title to align with the object on the far left within a Grid component using justify="space-between" in Material UI?

I am currently working on a Grid layout project that involves a Grid container with four Grid items. The first Grid item takes up the full width and contains a title, while the other three Grid items contain avatars. My goal is to align the avatars to the ...

Opt for the modal class over the id for improved functionality

How can I use this modal multiple times on the same page when it only works once due to the id element? Can someone assist me in making it work multiple times on the same page? I have tried the following code, but when I click the button, nothing happens. ...

Creating a HTTP Post request in Angular with DocRaptor to receive the download URL in the response

Struggling to integrate Angular5 with DocRaptor has led me to hit a roadblock. Surprisingly, the DocRaptor website lacks any documentation on how to combine it with Angular, only offering a beginner's guide for 'other'. I've scoured thr ...

Generate an inclusive list featuring li elements with intricately detailed content within each

Currently, I am in the process of developing a web component and here is my code snippet: <ul class="list-with-arrow${this.inverse ? '--inverse' : ''}"> ${this.listData.map((item, index) => { ...

What is the secret to getting this nested observable to function correctly?

Currently, I am working on an autocomplete feature that dynamically filters a list of meals based on the user's input: export class MealAutocompleteComponent { mealCtrl = new FormControl() filteredMeals: Observable<Array<Meal>> live ...

swapping out an external CSS file in React for a new CSS file

My React app is quite large and includes four main CSS files (darkLTR, lightLTR, darkRTL, lightRTL), which may not be the most efficient setup. The templates were provided by my boss, and I was instructed to use them instead of Material UI, which I initial ...

Overlapping Image Arrows with CSS Styling

After receiving a design with what appeared to be a simple feature from a designer, I discovered that implementing it was more complex than expected. Specifically, I needed to create a CSS3 arrow with an image as the fill color in order to overlap the unde ...

Is it possible to include a class in a 'label' element?

Forgive me if this is a simple question, but I'm curious - is it possible to add a class directly to a 'label' tag without needing to enclose it in a 'span' tag for styling? As I delve into "CSS: The Missing Manual," the book instr ...

Maintaining the aspect ratio of images in Bootstrap Carousel: A complete guide

Using the default carousel from Bootstrap template has been working well for me. However, I've encountered an issue where resizing the browser window distorts the image aspect ratio by squishing it horizontally. I've tried various solutions to m ...

how to enable drag and drop functionality based on names in angularjs

In my project using angular js, I have implemented a drag and drop feature that allows items to be dragged between cells in two directions. I now want to enhance this functionality by allowing members with 'a's (e.g. 1a, 2a, etc.) to be dragged ...

Reversed Sink CSS3 Animation moving to the left side

Currently, I am working on creating an animation that gives the illusion of a div sinking backward and then being pushed to the left once it has finished falling back. Although I am using CSS3 for this project, I am not very familiar with the animation pr ...