Is there a way to align these elements horizontally on the same line?

I am managing a website at

To better illustrate my request, I have attached an image showing what I want to accomplish. I would like the elements on the site to align seamlessly with the "in stock" notification.

https://i.sstatic.net/3qipq.jpg

This is the HTML code snippet:

<div class="single_variation_wrap" style="">
    <div class="single_variation">
         <p class="stock in-stock">Only 2 left in stock</p>
    </div>
    <div class="variations_button add-cart">
        <div class="cart-number">
            <span></span>
            <div class="quantity">
                <input type="number" step="1" name="quantity" value="1" title="Quantity" class="input-text qty text" size="4" min="1" max="2">
           </div>
       </div>
       <button type="submit" class="button single_add_to_cart_button alt btn-block">
           <i class="icon-cart2"></i>
           Add to cart              
       </button>
    </div>

    <input type="hidden" name="add-to-cart" value="1726">
    <input type="hidden" name="product_id" value="1726">
    <input type="hidden" name="variation_id" value="1922">
</div>

Can someone suggest a CSS solution for this issue?

I attempted to use the following CSS code, but it did not produce the desired result:

.cart-number {float:left;display:inline-block;}

Answer №1

Getting this right is not a quick and easy task. There are many components that need to be adjusted in order to achieve the desired result. Take a look at the attached images for reference. To make things easier, use either the 'Chrome Dev Toolbar' or Firebug from Firefox.

In the initial setup, the Wishlist button's div block was placed outside the FORM element, making it impossible to style inline. By moving it inside the FORM element, as shown in the first image, you can now achieve the desired layout.

After rearranging the elements and updating the CSS classes and styles, the Wishlist button now appears correctly aligned with other content. It may take some effort to ensure modular design, but with perseverance, you will be able to customize it accordingly. Refer to the second image for the final effect and note the highlighted section with added or modified CSS code.

Answer №2

Include the CSS property display:inline-block; in both elements with classes .button and .cart-number. This instruction will align the elements on a single line, eliminating the necessity of using float.

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

Incorporate a captivating background image into your SVG design

Currently working with Snap.svg, my aim is to include a background image on a polygon shape. The specific polygon in question is outlined as follows: <svg id="test" height="600" width="600" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink= ...

CSS Flexbox - Choose all elements that appear at the start of a new line (Wrap)

Is there a CSS selector that can prevent content insertion on new lines when using the wrap feature in CSS-Flexbox? I am utilizing CSS-Flexbox for a layout with the wrap option, but I do not know the number of lines beforehand. I need a solution where the ...

What is the procedure for making the menu background color transparent?

I need help changing the background color to transparent on my menu in desktop view. ul.dropdown-menu li { background-color: transparent !important; } <div class="collapse navbar-collapse navbar-ex1-collapse"> <ul id="menu" class="menu"> ...

"Select2 dropdown fails to function properly upon returning to the page using the browser's

I've encountered an issue while working on a search page with Select2 dropdowns. Everything functions smoothly upon the initial page load, however, problems arise when a user performs a search, hits the browser back button, and then revisits the page. ...

What is the correct way to utilize jquery's getJSON function?

<html> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#hidebtn").click(function() { ...

What causes the variation in the appearance of the navigation bar across different pages?

I'm struggling to understand why the Navigation bar has extra padding or margin on top only on certain pages, while it looks fine on the Homepage. I've dedicated countless hours to this issue and I am feeling completely frustrated. If you' ...

Automatically sorting data in JavaScript from PHP-generated JSON

When I receive JSON data from PHP and use it in JavaScript to populate a select box, the order is automatically sorted. This behavior should not occur. I am utilizing this JSON as the value for HTML select box options and I require the data to be in its o ...

Using jQuery to generate dynamic rows which are grouped according to JSON results

I am facing a situation where I have a JSON request returning specific data: [ {"ID":"57","BookName":"Title1","AuthorID":"2" "AuthorName":"Paul"} {"ID":"57","BookName":"Title1","AuthorID":"3" "AuthorName":"Mark"}, {"ID":"58","BookName":"Title2","AuthorID" ...

What is the process for adjusting the horizontal position of a flexbox using CSS?

Currently experimenting with flexbox to better understand its functionality. I have created the following layout: https://i.sstatic.net/rxvFD.png using the code provided below: .container-1 { display: flex; flex-direction: row; } .container-1 div ...

Troubleshooting: Unable to Remove Files in PhoneGap

I've been working on a basic app that heavily utilizes PhoneGap to test its capabilities. Currently, I'm trying to delete a file that has been downloaded within the app, but I'm encountering some issues. The majority of the code I've im ...

jQuery failing to recognize multiple selection form elements

<select class="js-example-basic-multiple categories form-control" name="categories[]" style="width: 100%" multiple="multiple"> <option value=""></option> <option value="fresher">fresher</option> <option value=" ...

Can I link the accordion title to a different webpage?

Is it possible to turn the title of an accordion into a button without it looking like a button? Here is an image of the accordion title and some accompanying data. I want to be able to click on the text in the title to navigate to another page. I am worki ...

Eliminating render-blocking CSS in PageSpeed - one stylesheet at a time

Currently, I am testing the best optimization practices for front-end development. As part of this process, I have utilized gulp and npm to merge and minify my CSS and JS files into a single all.min.css and js.min.css file. Upon analyzing my website using ...

Refreshing data dynamically in Laravel 8 without the need to reload the page

I need assistance in creating a live activities feed section for my website. My goal is to update the activities data without having to reload the entire page. Is there a way to achieve this? Below is the code snippet from the controller: public function ...

Obtain Data for Visualizing Graph with JSON within a Database-connected Graph (highchart.js)

In the process of creating a database-driven graph, I am utilizing libraries from Codepen. These libraries include: THIS and Highchart.js The HTML file on display simply showcases the chart, while the main data processing is handled in an index.js file t ...

Showcase a selection of items in a flexbox positioned vertically as a row

Check out my flexbox item and how it appears here This is the html code: <div id="property"> <div style="background-color:coral;"><img :src="item.property_image" width="200px" height=&qu ...

Crafting web design with media queries to ensure responsiveness

I have been working on creating a responsive webpage. While the header and footer are resizing properly when the browser is reduced in size, the navigation section is not behaving the same way. Currently, shrinking the page is causing the navigation block ...

AngularJS: ng-model not reflecting changes in entire object, only specific field within the object is being updated

I came across an issue while working on my AngularJS project. Here is the scenario: form.html: <form> <input ng-model="someVariable" type="text"/> </form> details.html: <div ng-include="'form.html'"></div> {{ s ...

Guide to displaying highcharts using external json data for numerous series

Having an issue with using angularjs and highcharts with multiple series where the data is coming from an external JSON file. When trying to access the data with a for loop using data.data[i].data, it's not working properly. Can anyone offer assistanc ...

Fluid container and confined container

Can someone explain the guidelines for when to use container versus container fluid in web development? What are some best practices and common pitfalls to avoid when using these two options? I would appreciate a clear explanation of the differences betwe ...