Tips for achieving perfect alignment in div elements

I'm having an issue with my code where I want to display a page with 3 images - one on the left and the other two on the right side. However, all the images are displaying in the same line instead of following the order I have given. Can someone please assist me in resolving this?

  1. List item

    have given. please help me in solving these.

.leftAlign {
    float: left;
}
.rightAlign {
    float: right;
    margin: 10px;
}
.rightOrder{
    float: right;
    margin: 10px;
}
.primary-button {
    background-color: #109bd5;
    color: white;
  }
<div class="about-content">
  <h4 mat-dialog-title>Hello World</h4>
    <div mat-dialog-content>
      <div class='leftAlign'>
        <h4>IMAGE1</h4>
        <img src="assets/images/image1.png">
      </div>
      <div class='rightAlign'>
        <h4>IMAGE2</h4>
        <img src="assets/images/image2.png">
      </div>
      <div class='rightOrder'>
        <h4>ICON</h4>
        <img src="assets/images/icon_img.png">
      </div>
    </div>
    <div mat-dialog-actions align="end">
      <button mat-button mat-dialog-close class="mat-button               primary-button">close
      </button>
    </div>
</div>

Answer №1

<div style="display:flex;justify-content:space-between;">
          <div>
            <!-- Left aligned content -->
            <img src="https://via.placeholder.com/150?text=1" alt="image 1">
          </div>
          <div>
            <!-- Right aligned content -->
           <div>
             <img src="https://via.placeholder.com/150?text=2" alt="image 2">
           </div>
           <div>
             <img src="https://via.placeholder.com/150?text=3" alt="image 3">
           </div>
          </div>
        </div>

If you are using Bootstrap, consider utilizing it instead of applying inline styles.

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

Using HTML and CSS, design a customizable tick box without explicitly utilizing the 'checkbox' element

Check out this code snippet (and yes, I'm using a basic reset.css): .checkbox { border: 1px solid black; width: 10px; height: 10px; } <ul> <li> <p><div class="checkbox"></div>I agree!</p> </li&g ...

How can I modify the data within a PHP-generated table displayed on an HTML page?

As part of my school coursework, I am working on a computing project that involves PHP, HTML, and MySQL to create a web-based application. In the database "cp11641_users," there is a PHP table named "users" which has been displayed in an HTML table using ...

Navigating through the sticky top navbar in Bootstrap 4 by swiping

I've encountered an issue with a sticky-top navbar that has dropdowns with multiple buttons each. On smaller devices, the navbar gets cropped and I'm unable to access the lower buttons. I'm looking for a solution to add scrolling to this nav ...

What are the basics of floating elements and how can it be effectively utilized in CSS3?

I can't wrap my head around this property. First, let me share what I know about it. I'm focusing on the <p> element with id="amazing" for this discussion. Let's set a width for it #amazing{ width: 200px } The outcome is: Since ...

Issue with Chrome on android causing local website javascript and css to not load properly

The issue I am experiencing is unique to Chrome for Android when accessing a local website. Interestingly, the site functions perfectly on Firefox for Android but encounters problems on Chrome. Specifically, on my website , there is a download link for a ...

Creating a dropdown navigation menu

I am trying to create a smooth slide down menu effect, but it seems to instantly expand with no transition. Can anyone help me troubleshoot this issue? const Container = styled.section` position: relative; overflow: hidden; ` const WrapperItems = st ...

What's the deal with toggleClass() not functioning properly?

I am facing an issue with a simple class toggle in jQuery. Despite my best efforts, it is not working as intended. The expected behavior is to toggle the class of the <p> when clicking anywhere on the label. It does work correctly if the checkbox is ...

utilizing AJAX in PHP for a dynamic selection process with MariaDB

I am working on a dynamic select feature using AJAX, PHP, and queries to a database. There are three main components involved in this process: the HTML where the select options are populated from database queries done through AJAX, the PHP scripts that han ...

Insert a new element following each ng-repeat iteration

I have a situation where I am using ng-repeat and I want to insert a new element after every 4th repetition. Here is the code for the repeated div: <div class="product" ng-repeat="product in productList" ng-init="addFullScreenProduct($index, t ...

Switch up the display of table rows with a convenient Toggle Button located right after the

Looking for a way to toggle the visibility of certain rows in an HTML table using a button but having trouble placing the button after the table instead of before. Any suggestions on how to customize this setup? Thanks! /*Use CSS to hide the rows of t ...

Tips for organizing and centering Kendo radio buttons within a Bootstrap grid and form structure

After trying the Bootstrap method [3] without success, I am now implementing the radios according to approach [1]. Even after applying the fix for box-sizing as suggested in [2], it doesn't seem to resolve the issue. <div class="panel panel-defa ...

I am eagerly awaiting for the table command "rowspan" to finally start functioning properly. Right now, it seems to be completely ignored

While working on my html project to create a basic table, I encountered an issue halfway through. My goal was to make the second to last row double in size by using rowspan="2", but unfortunately nothing changed. Can someone assist me with this problem? ...

Tips for creating space between flex elements in Bootstrap without disrupting the layout breakpoints

<div class="row"> <div class="col-sm-6" style="margin-right: 1px;">CONTENT</div> <div class="col-sm-6"> CONTENT</div> </div> When adding a margin to the first element, it causes th ...

How can you use ES6 pure Javascript to set the src attribute of an html collection of images from an array of paths as values for each image?

Currently, I have an array filled with different src values like [path1, path2, path3], and a corresponding HTML collection which has the same number of elements as the array. I am looking for a way to assign each value from the array to set the src attrib ...

Utilizing the smallslider feature through jQuery/JavaScript operations

I've recently embarked on the journey of learning JavaScript/jQuery. I've been attempting to incorporate this cool effect, but unfortunately, I'm facing some difficulties with it: My goal is to understand how to execute this effect using Ja ...

Update Bootstrap Vue to change the colors of the breadcrumbs

Struggling to customize the look of bootstrap-vue breadcrumbs? I've attempted various combinations of classes and styles in the breadcrumb and breadcrumb-item tags, but to no avail. Every time, I end up with blue or grey text on a light grey backgroun ...

Jquery CSS malfunctioning on Post's div element

After retrieving a div using jquery's post method on my page, I am encountering an issue when attempting to apply CSS to the divs. Strangely enough, applying CSS with jquery to divs that are already present on the page works perfectly fine. Javascrip ...

Transforming web content from HTML into text format and subsequently reinserting it into HTML for webpage integration

Our current process involves using an XML feed along with jquery and ajax to retrieve data, which is then parsed for display on the webpage. var des = $(this).find("Description").text(); var trimmed= des.substring(0, 300); if (trimmed.length <= 300) { ...

Is it possible to refresh a div on one .aspx page using content from another .aspx page?

Just beginning my journey with asp.net and currently tackling a project that involves two .aspx pages. Events.aspx: This page is where the site admin can update upcoming events and webinars using an available panel to input event title, date, information ...

The stylesheet reference, <link rel="stylesheet" href="../css/style.css">, appears to be malfunctioning

My project structure includes css files in a folder named css and jsp files in a folder named jsp, both located inside the WEB-INF folder. I am wondering how to access the css file within a jsp file. <link rel="stylesheet" href="../css/style.css> T ...