Placing a pair of buttons side by side

Having some trouble with my design.

I've got a product page with two buttons, but because one is in a form, they're stacked on top of each other (see image).

https://i.sstatic.net/cS9TI.jpg

How can I get these two buttons to sit next to each other? Any assistance would be greatly appreciated. Below are the HTML and CSS snippets I'm currently working with.

Thanks so much in advance!

HTML:

<!DOCTYPE HTML>
<div class="container text-center">
            <div class="sale">
                <h1>On Sale</h1>
                <p class="text-secondary">
                    We have new sales promotions online for a short period of time every day. We offer products from
                    popular labels and luxury brands in the lifestyle segment up to 75% cheaper than the
                    recommended retail price.
                </p>
            </div>
</div>

        <section class="on-sale">
            <div class="container">
                <div class="row">

                <?php
                    for($i = 0; $i < $countProductItems && $i < 4; $i++){
                        ?>
                        <div class="col-md-3">
                        <div class="product-top">
                        <a href="products/product-page.php?product=<?php echo ($saleProducts[$i]['strProductNaam']); ?>" onclick="POST"><img src="<?php echo ($saleProducts[$i]['imgProduct1']);?>" class="img-fluid" alt="Product1"/></a>
                            <div class="overlay-right text-center">
                                <button type="button" class="btn btn-secondary" title="Quick Shop">
                                <a href="products/product-page.php?product=<?php echo ($saleProducts[$i]['strProductNaam']); ?>" onclick="POST"><i class="fa fa-eye text-white"></i></a>
                                </button>
                                <form action="includes/shopping-cart.inc.php?action=add&id=<?php echo ($saleProducts[$i]['ID'])?>" method="post">
                                    <input class="text-center" type="hidden" name="quantity" value="1"/>
                                    <input type="hidden" name="index-page" value="index">
                                    <input type="hidden" name="product-name" value="<?php echo ($saleProducts[$i]['strProductNaam']); ?>">
                                    <input type="hidden" name="product-price" value="<?php echo ($saleProducts[$i]['strSalePrijs']); ?>">
                                    <button type="submit" class="btn btn-secondary " title="Add to cart" name="add_to_cart"><i class="fa fa-shopping-cart"></i></button>
                                </form>
                            </div>
                        </div>
                        <div class="product-bottom text-center">
                        <p>
                                <?php rating_star(($saleProducts[$i]['RatingStar'])) ?>
                            </p>
                            <p><h3><?php echo ($saleProducts[$i]['strProductNaam']); ?></h3></p>
                            <?php sale_product(($saleProducts[$i]['intPrijs']), ($saleProducts[$i]['strSalePrijs']))?>
                        </div>
                    </div>
                    <?php
                    }
                ?>

                </div>
            </div>
        </section>
</html>   

CSS:

.container .sale{
    padding: 3rem 0;
    }

    .container .sale{
        font-family: var(--gugi);
    }

    .container .sale{
        padding: 0.5% 25%;
        font-size: 0.9em;
    }

.on-sale{
    margin: 50px 0;
}

.on-sale img{
    width: 100%;
    padding: 20px;
    transition: 1s;
    cursor: pointer;
}

.on-sale img:hover{
    transform: scale(1.1);
}

.product-top{
    width:100%;
    display: inline-block;

}

.product-bottom .fa{
    color: orange;
    font-size: 10px;
}

.product-bottom h3{
    font-size: 20px;
    font-weight: bold;
}

.product-bottom h5{
    font-size: 15px;
    padding-bottom: 10px;
}

.make_red {
        color: red;
}        

// codefilling text[error] - nfnjsnfjsfnbjkdsnfdsfndjsfbjabsdjhbgdgabadsg

Answer №1

You should consider implementing display:flex in your CSS code.

.overlay-right text-center{
    display: flex;
    justify-content: space-between;
    width: 200px;
    margin: 0 auto;
    align-items: center;

}

Answer №2

To change the display of a form to inline in your CSS, use the code display: inline. By default, a block display is applied to a form

Answer №3

Here's another suggestion to consider:

button {
  display: inline;
  margin: auto;
  padding: 5px;
}

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

Angular's Motion Module

Incorporating Angular-5 into my project has introduced a plethora of animations on various pages. While the utilization of jQuery provides a straightforward approach for adding and removing classes to DOM elements, it is frequently advised against using jQ ...

Troubleshooting text-rendering CSS issues in Netbeans

body, html{ font-family: 'Lato', sans-serif; text-rendering: optimizeLegibility !important; -webkit-font-smoothing: antialiased !important; color: #5a5a5a; } there was a CSS parsing error due to an unrecognized property ...

migrate the HTML variable to PHP

Hello, as a beginner in php, I have a question regarding storing the var effort value from an html5 canvas code into a php session for transfer to mysql. Can someone provide guidance on how to achieve this? Your assistance is greatly appreciated. <di ...

Struggling to map JSON data (received from WCFRest) onto an HTML table

After creating a WCFRestful service that populates data in JSON format as shown below: {"GetEmployeesJSONResult":"[{\"Name\":\"Sumanth\",\"Id\":101,\"Salary\":5000},{\"Name\":\"Sumanth\",\"I ...

Learn how to collapse a list by clicking outside of it on the document with the following code: $(document).on("click"

I want to create a collapsible/expandable menu for my website. I had a version where hovering over a category would expand the subcategory, but what I really need is for the subcategories to expand when I click on a category and remain expanded until I cli ...

Steps to Import an Image from a Subdirectory:

Currently, I am working on C# and HTML. While working on a view page, I encountered an issue when trying to load images from subfolders. When attempting to load an image from the immediate folder, it opens correctly. For example: <img data-u="image" s ...

Tips for properly aligning blockquote opening and closing quotation marks

We are currently implementing custom styles for beginning and end quotes in a string using the <blockquote> tag. However, we are having issues with the alignment, as the opening quote appears before the text and the closing quote is at the end of the ...

What is the best way to manage the back button functionality on pages that use templates?

I am currently developing a website using angularjs. The layout consists of two main sections: the menu and the content area. For instance This is an example page: /mainpage <div> <div id="menu"> <div ng-click="setTemplate('fi ...

Display unique JQuery special characters

I'm looking to modify this specific text Hello Mr ABC so that it appears as: Hello "Mr ABC". The text Mr ABC includes a unique non-printable character " ". P.S: Where can I find more information on this topic? ...

When PHP is connected to the database, Ajax remains inactive and does not perform any tasks

I am currently working on setting up a simple connection between JavaScript and my database using ajax and PHP. The goal is for JavaScript to receive a name from an HTML form, make changes to it, send it to PHP to check if the name already exists in the da ...

I am facing an issue where the display property of inline-block is taking precedence over

I am facing a challenge in placing 2 containers side by side. These containers have a thick white border and are initially hidden until a click event reveals them. The containers are given a class of "hidden". However, in order to align the div containers ...

Conceal the pop-up when the user selects anywhere else on the webpage

Is there a way to hide this navigation bar when the user clicks anywhere else on the page, other than on the navbar elements? Appreciate your help. https://i.sstatic.net/h82n1.png ...

What is the true functionality of the Bootstrap Grid system?

I am currently in the process of grasping how this functions. As an example, I have created columns and inserted <hr> for visualization purposes. This is what I have attempted thus far: I adjusted the row's margin to be -15px on both sides. C ...

Create Stylish Popups and Spacious Containers with CSS

A unique pure css popup was crafted by merging and . Hovering over "John Smith" triggers the appearance of the popup. The code for this can be seen at http://codepen.io/kikibres/pen/MwEgQX. However, there are some challenges being faced. The aim is to ke ...

Displaying the Selected Value from the DropDown in the Menu

I am working with Bootstrap5 and have the following dropdown menu in my code. Instead of displaying "Year," I would like to show which member was selected. How can I achieve this? <div class="dropdown"> <button class="btn btn- ...

What is the process for incorporating a button to the left of the search field?

Is it possible to enhance the search field by adding a button to make it more user-friendly? Below is the code I have been using: <div id="search"> <div class="container"> <h1>Search U.K. house price data</h1> <form c ...

Transform the inline style attributes found in the HTML code into CSS styling

After creating a webpage using Bootstrap Studio, I realized that all the style attributes are inline and I want to move them to a separate CSS file. However, I am facing difficulty in doing so as when I add an image using 'background-image:url('i ...

Progress bar using jQuery inside a list of tree folders in CSS

I have a folder tree structure and I would like to include a progress bar alongside each folder name, which is also a clickable link. The progress bar will be created using jQuery UI. The pblabel element should appear on top of the progress bar. The bar e ...

What is the most effective way to monitor the duration of video playback?

Whenever a user watches a video, I aim to initiate 2 AJAX calls. The first call should trigger when the user finishes watching the entire video or if the time played is equal to or greater than the duration of the video (considering users may rewind). time ...

Is there a way to horizontally align text in a div using center alignment?

Excuse me for what might seem like a silly question, but I am having trouble figuring this out. Edit: All I want is to horizontally center the text without affecting the image's position. The image should stay aligned with the baseline of the text. ...