What is the best way to position a button and text at the bottom right corner in HTML?

Is there a way to align a button and text on the bottom right in html? I am trying to create a layout where a button is at the bottom right with text next to it, similar to online stores ... Why are there 3 buttons at the top and the last one at the bottom?

.flex-middle {
  display: flex;
  flex-direction: row;
}

body {
  background: #fff;
  /* Background color */
  color: #800080;
  /* Text color */
}

bottombanner {
  display: table;
}

.col-sm-3 {
  display: table-cell;
  vertical-align: middle;
}

button {
  position: absolute;
  right: 10px;
  bottom: 10px;
}
<!DOCTYPE html>

<head>
  <meta charset="utf-8">
  <title>Best Products In The World!</title>
</head>

<body>
  <h1 align="center">Affordable Phones</h1>
  <h2 align="center">Find low-priced phones here</h2>
  <hr>
  <p>
    <div class="flex-middle">
      <img src="C:\Users\Misha\Pictures\s-l640.jpg" width="200" height="200"><a>$100</a>
      <p>
        <input type="button" value="Buy Now">
      </p>
      <img src="C:\Users\Misha\Pictures\iphone-11-pro-max-gold.jpg" width="210" height="210" alt="$500">
      <a>$500</a>
      <p>
        <input type="button" value="Buy Now">
      </p>
      <img src="https://i.allo.ua/media/catalog/product/cache/1/image/524x494/602f0fa2c1f0d1ba5e241f914e856ff9/0/_/0_59_16_1_1.jpg" width="200" height="200"><a>$300</a>
      <p>
        <input type="button" value="Buy Now" onclick="window.location.href='https://example.com/'">
      </p>
      <div class="col-md-6" style="margin-top: -2%; position: inherit;">
        <img style="padding: 20px;" src="https://i8.rozetka.ua/goods/21350797/copy_huawei_p_smart_2021_128gb_green_5ffd6e36c99dd_images_21350797501.png" width="150" height="210">
        <span style="style=" vertical-align: 5px;"><a>$400</a> </span>
        <p>
          <input type="button" value="Buy Now" onclick="window.location.href='https://example.com'">
        </p>
      <div>

Answer №1

The final items in your inventory were stored within a div due to this specific reason, and the previous method was accurate. I have placed other products inside a div and included text-align: right;. Consequently, the button and text are now aligned at the bottom and positioned to the right.

div {
text-align: right;
}
<!DOCTYPE html>
<head>
   <meta charset="utf-8">
   <title>Best Products in the World!</title>
</head>
<style>
   .flex-middle {
   display: flex;
   flex-direction: row;
   }
   body {
   background: #fff; /* Background Color */
   color: #800080; /* Text Color */
   }
   bottombanner {
   display: table;
   }
   .col-sm-3 {
   display: table-cell;
   vertical-align: middle;
   }
   button{
   position: absolute;
   right: 10px;
   bottom:  10px;
   }
</style>
<body>
   <h1 align="center">Affordable Phones</h1>
   <h2 align="center">Find phones at low prices here</h2>
   <hr>
   <p>
   <div class="flex-middle">
   <div>
      <img src="C:\Users\Misha\Pictures\s-l640.jpg" width="200" height="200"><span>7000 UAH</span>
      <p><input type="button" value="Buy"></p>
   </div>
   <div>
      <img src="C:\Users\Misha\Pictures\iphone-11-pro-max-gold.jpg" width="210" height="210" alt="36999">
      <span>3699 UAH</span>
      <p><input type="button" value="Buy"></p>
   </div>
   <div>
      <img src="https://i.allo.ua/media/catalog/product/cache/1/image/524x494/602f0fa2c1f0d1ba5e241f914e856ff9/0/_/0_59_16_1_1.jpg" width="200" height="200"><span>5499 UAH</span>
      <p><input type="button" value="Buy" onclick="window.location.href='https://allo.ua/'"></p>
   </div>
   <div class="col-md-6" style="margin-top: -2%; position: inherit;">
   <img style="padding: 20px;" src="https://i8.rozetka.ua/goods/21350797/copy_huawei_p_smart_2021_128gb_green_5ffd6e36c99dd_images_21350797501.png" width="150" height="210"> <span style="style="vertical-align: 5px;"><span>4999 UAH</span> </span>
   <p><input type="button" value="Buy" onclick="window.location.href='https://cutt.ly/Sc5kIPN'">    </p>
   <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

Menu Tabs with Rounded Edges

Seeking help to round the corners of a tabbed dynamic menu using Drupal and the dynamic-persistent-menu module. The code provided below is almost perfect, with 99% accuracy. View the current state of the menu here: . Can anyone assist in achieving the rema ...

Updating the source of an image without having to refresh the entire webpage

I've encountered a slight issue that has me feeling like I'm going in circles. Currently, I'm immersed in a project where I must dynamically update the <img> src attribute with various images after unpredictable intervals (without empl ...

Concealing the HTML button on a mobile display

On my website, I have a button that leads users to the next section of the page. I am trying to hide this button in mobile view but I am struggling to find the correct CSS code to do so. Check out the JSFIDDLE for the code: https://jsfiddle.net/cgqme8xo/ ...

Troubleshooting the malfunction of the CSS display property

I've created a div with a number displayed initially. When I hover over the div, the number disappears and a paragraph is revealed. Upon hovering out, the paragraph hides and the number reappears. My attempts to achieve this using CSS (display: none ...

Ways to postpone CSS and Script loading once JavaScript has been executed

My issue with my backbone.js app is that I have noticed some slow loading files (a .css and a .js) that are causing the page to block until they are fully loaded. After rendering the backbone view, I am looking for a way to delay the loading of these file ...

How can I ensure my game or website fits perfectly on the screen without any need

I have recently developed a fun Erase-A-Man game that is optimized for mobile devices. However, I am facing an issue where users need to scroll to view all the letters on their screens. My goal is to make the game fit perfectly on all phone screen sizes so ...

Tips for waiting on image loading in canvas

My challenge involves interacting with the image loaded on a canvas. However, I am uncertain about how to handle waiting for the image to load before starting interactions with it in canvas tests. Using driver.sleep() is not a reliable solution. Here is ...

Tips for displaying information in an Autosearch feature

I am trying to implement an auto search feature using AJAX calls, but I am facing difficulties in displaying the results on the search bar. The search results are showing up properly elsewhere. <input type="text" id="select_link" placeholder="enter th ...

A step-by-step guide on splitting an element into two separate elements using jquery

I have the following code snippet: <h4>user (role) on 26 Nov 2018 20:39:42 +00:00:</h4> My goal is to transform it into this structure: <h4>user (role)</h4> <p>on 26 Nov 2018 20:39:42 +00:00:</p> The <h4> eleme ...

When dynamically adding rules to jQuery validate, I encountered an unexpected error

My dynamic form validation with jQuery validate involves a drop-down menu on my HTML that includes values 1, 2, 3, and 4. Depending on the selection made from the drop-down, different div elements are displayed with corresponding fields. All the input fie ...

Is it possible to arrange elements in CSS based on their attribute values?

I need to arrange a list of images in ascending order based on the index attribute using CSS. The challenge is that the index values will change dynamically and new images will be added through Ajax, so I want them to automatically update in the correct or ...

Tips for adjusting the font color of user-provided text within an input box using HTML and CSS

HTML code:- <p><input type="text" placeholder="Enter your username"></p> CSS code:- .main-header input { width: 90%; padding: 1rem; margin: 20px 0px; border: none; border-bottom: 4px solid #5f5fb0; ...

javascript: Make sure to update the DOM only after the result has been successfully obtained

I have access to an API endpoint that returns server details (). There are also server-specific endpoints, for example () where I have to call each one for every server ID obtained from the "serverDetails" endpoint. My current approach involves looping ov ...

Marking table entries to prevent their display once that row of entries has been chosen/utilized

Being new to programming, I'm unsure if the title of my issue is appropriate, but here's what I'm facing: I've created a basic inventory program that allows me to add, modify, and delete entries successfully. Now, for my next task, I w ...

How to use CSS to align text at the bottom of Angular Material icons within spans?

Looking for assistance with this code snippet. I am trying to align the text within the spans to the bottom of the stars. <ng-container *ngIf="starCount"> <span>Not Relevant</span> <button mat-icon-button ...

What is the best way to send the results of a controller function's calculations to a directive in HTML?

Query from Angular Beginner: I am looking to execute a function myFunc in my AngularJS controller (myController) that computes values aB and aC. Subsequently, I want the HTML to pass these calculated values as arguments to a directive called myDirective. ...

When capturing photos using h5 on iOS devices, the browser may experience a flash back issue

I have been searching Baidu and Google for a while now, but I still haven't found a solution. Here is the specific issue: When using h5 to take photos on iOS systems, the browser flashes back. HTML Code <img src="xxx" onclick="sta ...

Place an element in relation to its initial position, ensuring that the x-coordinate is not set to 0

Is there a method to place an element in relation to its initial position, only excluding x=0 - meaning that the element is placed at its original vertical coordinate but sticks to the window's left edge? ...

Transform the header style columns of react-js Material-tables into rows

Currently experimenting with gradient designs on a material table. While I am able to apply the right color combination to the rows, I seem to be getting column-based results on the title of the table. Attached is a screenshot of my output for reference. ...

I am experiencing issues with the background image not displaying correctly on Safari when accessing from my

I recently uploaded my simple website, but I encountered an issue when viewing it on my phone using the Safari browser. The background image at the top is not displaying properly. I attempted solutions from this and this, but unfortunately, none of them re ...