Align the button to the right side inside a div container

As someone who isn't very skilled in CSS, I have a question for beginners. Below is an excerpt from an HTML document:

<div _ngcontent-vyb-c4="" class="form-row">
       <div _ngcontent-vyb-c4="" class="col-md-12">
          <div _ngcontent-vyb-c4="" class="form-group">
             <h5 _ngcontent-vyb-c4="">Contract</h5>
             <button _ngcontent-vyb-c4="" class="buttons-form mat-mini-fab mat-button-base mat-primary" color="primary" mat-mini-fab="" type="button" ng-reflect-color="primary">
                <span class="mat-button-wrapper">
                   <mat-icon _ngcontent-vyb-c4="" class="mat-icon notranslate material-icons mat-icon-no-color" role="img" aria-hidden="true">settings</mat-icon>
                </span>
    ...

I'm wondering how to position the button next to the icon on the right side of the h5 element, aligned all the way to the far right. The current layout can be seen in this screenshot. My goal is to have the gear icon and the button displayed on the same row https://i.sstatic.net/j9pcA.png. Please note that this is part of an Angular project, if that makes a difference.

Answer №1

Using flexbox can easily align the items in a row.

.form-group {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}
<div _ngcontent-vyb-c4="" class="form-row">
   <div _ngcontent-vyb-c4="" class="col-md-12">
      <div _ngcontent-vyb-c4="" class="form-group">
         <h5 _ngcontent-vyb-c4="">Contract</h5>
         <button _ngcontent-vyb-c4="" class="buttons-form mat-mini-fab mat-button-base mat-primary" color="primary" mat-mini-fab="" type="button" ng-reflect-color="primary">
            <span class="mat-button-wrapper">
               <mat-icon _ngcontent-vyb-c4="" class="mat-icon notranslate material-icons mat-icon-no-color" role="img" aria-hidden="true">settings</mat-icon>
            </span>
...

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

CSS: The background color of the body is appearing correctly when viewed locally, but does not display on

I had been using the styles.css file with this body stanza: body { font: 18px Helvetica, sans-serif, Arial; color: #ffffff; background: url("../images/bg.jpg") center top repeat-x; background-size: cover; line-height: 20px ...

Is there a way to change the text (price) when I select an option?

<div class="single-pro-details"> <!--Customize in the CSS--> <h6>Home / Beats</h6> <h4>Unique Lil Tecca Type Beat - New Love</h4> <h2 id="price">$ ...

Reveal a concealed div in a modal form depending on the value present in the input field

After spending the past 4 hours scouring through Google and SO, I finally stumbled upon an answer HERE that seemed to be somewhat close to what I was looking for. However, in my scenario, the <div class="fhlbinfo"> elements are not displaying or hi ...

Encountering the "Local resource can't be loaded" error when attempting to link a MediaSource object as the content for an HTML5 video tag

I'm attempting to make this specific example function properly. Everything runs smoothly when I click the link, but I encounter an error when trying to download the HTML file onto my local machine and repeat the process. An error message pops up sayi ...

What steps can I take to fix the sum function?

My function calculates heart rate targets for sports, but there seems to be an issue in the switch statement. The final sum in the function is not being computed properly. For example, if someone is 20 years old with a resting heart rate of 50 beats per mi ...

ReactJS component experiencing issues with loading images

In my React project, there is a directory containing several images, and I am attempting to import them all into a carousel using Bootstrap. The current code looks like this: import Carousel from 'react-bootstrap/Carousel'; const slideImagesFold ...

Choose from a variety of options for color schemes and hover effects

Looking to create a selector where users can pick a color. I tried changing the background color for each option, but when hovering over them, the background turns blue - which is not what I want. Check out the pictures for clarification: https://i.sstatic ...

Firefox is not rendering HTML5 elements properly

While my website performs well in Chrome and Safari, there seems to be an issue with how elements are displayed in Firefox or IE. Some elements are being pushed to the right, and I am unsure of how to fix this problem. You can view the site here To aid i ...

Are there any images included in the WebResponse being downloaded?

I need to download HTML efficiently in order to parse it with minimal bandwidth consumption. Here is a snippet of my code: if (!String.IsNullOrEmpty(siteAddress)) webReq = WebRequest.Create(siteAddress) WebResponse webRes ...

Issue arises when trying to insert an image avatar onto a globe in three.js

I have successfully implemented a rotating 3D globe using three.js with the code provided below. HTML <canvas id="canvas"></canvas> JS let camera; let renderer; function main() { const canvas = document.querySelector('#ca ...

Troubleshooting Problems with CSS Before Selector and Margins

Currently, I am attempting to utilize the before selector in order to replicate some list item behavior for elements. Due to constraints where I cannot use list items, it is crucial that I find a way to make styles work effectively. If you would like to s ...

Arrange the side by side display of uploaded image previews

Could someone please assist me with aligning my image upload preview in a row, similar to a brand/partners slider? The current preview output is not displaying as desired. Here is the code I have: <div class="image-gallery"> <div class ...

Closing Note in Drupal

Is there a way to adjust the footer message in Drupal without logging into the dashboard? I've checked all the files in cPanel, but I can't seem to locate the actual HTML for the website. I am only able to customize the body content, not the fo ...

What are the best strategies for ensuring this website is fully optimized for all devices

Hi there, I've been struggling to make the header on my website responsive, but it doesn't appear to be functioning properly. Any assistance would be greatly appreciated. <!DOCTYPE html> <html lang="en"> <head> <meta name="v ...

AngularJS, Gridster, and n3-charts are causing a $digest error in Chrome and Firefox, but not in Safari

My project involves developing an Angular app to generate a dashboard featuring various charts within gridster items. The dashboard layout is structured using Angular-gridster, while the charts utilize n3-charts. When attempting to display a chart within a ...

What is the best solution for setting up a div containing a table with images inside?

I'm looking to achieve the following: <div id="display"> <div id="slideshow1"> <table cellspacing=0><tr><td style="height:200px;padding:0;vertical-align:middle"> <img ... /> </td></tr> ...

Code that achieves the same functionality but does not rely on the

I utilized a tutorial to obtain the ajax code below. The tutorial referenced the library jquery.form.js. Here is the code snippet provided: function onsuccess(response,status){ $("#onsuccessmsg").html(response); alert(response); } $("# ...

Tips for utilizing the Spacing Utility Classes in Bootstrap

While browsing through an article, I came across Bootstrap 4 Spacing Utility Classes, particularly the m-b-lg class used in the className section. <div class="row"> <div class="col-sm-6 m-b-lg"> <!-- column-small-50%, margin-bot ...

Adding a close icon to the mobile menu in Bootstrap 5: A step-by-step guide

As a newcomer to web development, I am currently working on creating a responsive/mobile menu with a close icon for Bootstrap 5. Despite my efforts and exploration, I have been unable to successfully add the close icon to the mobile menu. Any assistance i ...

Exploring the asp.net MVC framework with the integration of HTML5 date input

Currently, I am working on an ASP.NET MVC project using Visual Studio 2013. One of the issues I am encountering is related to a date input field. When I click on the field and focus on it, the automatic HTML5 datepicker does not appear. If I enter the da ...