Arranging Checkboxes Vertically in HTML Without Using Inline Styling

My checkboxes are currently displayed in a column format, but I would like them to be in a single row.

To better illustrate the issue, here is a photo: https://i.sstatic.net/PxRzB.jpg

I am seeking assistance on how to align the checkboxes horizontally instead of vertically.

.lowerToppings
{
  display: flex;
  justify-content: space-around;
}

.LowerToppingsCheckBoxes{
 display: inline-block;
   display: -moz-inline-box;
   *display: inline;
   zoom: 2; 
   width: 10%;
   text-align: center;
}
<div class="lowerToppings">
  <img src="olivee.jpg" width="100" height="100">
  <img src="onion.jpg" width="100" height="100">
  <img src="bellpepper.jpg" width="100" height="100">
  </div>

  <br></br>

  <div class="LowerToppingsCheckBoxes">
  <div><input type="checkbox" id="cheese" name="toppings" value="cheese"></div>
  <div><input type="checkbox" id="pepperoni" name="toppings" value="pepperoni"></div>
  <div><input type="checkbox" id="mushroom" name="toppings" value="mushroom"></div>
  <div><input type="checkbox" id="pepper" name="toppings" value="pepper"></div>
  <div><input type="checkbox" id="basil" name="toppings" value="basil"></div>
  </div>

Answer №1

<div class="ToppingsSelectionBoxes">
    <input type="checkbox" id="cheese" name="toppings" value="cheese">
    <input type="checkbox" id="pepperoni" name="toppings" value="pepperoni">
    <input type="checkbox" id="mushroom" name="toppings" value="mushroom">
    <input type="checkbox" id="pepper" name="toppings" value="pepper">
    <input type="checkbox" id="basil" name="toppings" value="basil">
</div>

.ToppingsSelectionBoxes{
  ...
  flex-direction: row; // remember to add this
}

To accommodate all the checkboxes, consider increasing the width of the container.

Answer №2

.lowerToppings
{
    display: flex;

    justify-content: space-around;

}

.LowerToppingsCheckBoxes{
   display: inline-block;
   display: -moz-inline-box;
   *display: inline;
   zoom: 2; 
   width: 200px;
   text-align: center;
}
.LowerToppingsCheckBoxes div{display:inline-block;}
<div class="lowerToppings">
    <img src="olivee.jpg" width="100" height="100">
    <img src="onion.jpg" width="100" height="100">
    <img src="bellpepper.jpg" width="100" height="100">
    </div>

    <br></br>

    <div class="LowerToppingsCheckBoxes">
    <div><input type="checkbox" id="cheese" name="toppings" value="cheese"></div>
    <div><input type="checkbox" id="pepperoni" name="toppings" value="pepperoni"></div>
    <div><input type="checkbox" id="mushroom" name="toppings" value="mushroom"></div>
    <div><input type="checkbox" id="pepper" name="toppings" value="pepper"></div>
    <div><input type="checkbox" id="basil" name="toppings" value="basil"></div>
    </div>

Answer №3

If you adjust the display property of .LowerToppingsCheckBoxes to flex, it will align your checkboxes in a row.

.LowerToppingsCheckBoxes{
   display: flex;
   display: -moz-inline-box;
   zoom: 2;
   width: 10%;
   text-align: center;
}

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

Position two child divs side by side within a parent div

Here's what I have accomplished so far: http://jsfiddle.net/cHKF4/3/ However, I am aiming to incorporate small boxes (box1 and box2 inside late) #late { position: relative; border-style: solid; border-width: 3px; border-color: #00ff ...

What are some possible applications for leveraging the HTML5 <link rel> attribute duo of stylesheet and next?

The specification for HTML5 emphasizes the handling of each link created within a link element as separate entities. This means that multiple link elements with `rel="stylesheet"` are treated independently, considering them as distinct external resources a ...

Ways to automatically scroll text inside a div based on the div's width

I currently have a div with a fixed width. My goal is to automatically scroll the text (left and right in a horizontal direction) within the div if the content exceeds the width of the div. How can I achieve this using CSS or jQuery? The class for the div ...

Even though the if statement has been implemented, the page continues to show null objects

So, I have an if statement that filters out null objects and it's working fine. However, when I try to insert something in join() like join("li"), all null objects are displayed on the page as shown in the image. I just want to display objects that ar ...

What is the best approach to choose the thead element from a dynamically created table?

My table in JavaScript/JQUERY is dynamically constructed. Once the table is created, I am attempting to target the thead element. Here is a snippet of my code: $(document).ready(function(){ buildTbl(); }); function buildTbl() { var tbl = '< ...

Is resizing possible using the Canvas identifier?

Is it possible to adjust the canvas size to match the width of the page using the canvas id's style in the html? Then in your javascript code for the canvas, can you have resize listeners that are responsive to the canvas size at any given time? I c ...

css - targeting the last child element using a type selector

I'm attempting to target the final child element of type <div> within the container "#myDiv" <div id="myDiv"> <div> <img> <div> <div>text</div> ...

Table lines that are indented

I am currently in the process of transforming a standard HTML table into an indented version like this: Is there a way to hide the initial part of the border so that it aligns with the start of the text, even if I can't do it directly in HTML? ...

There seems to be an error with JVectorMap: the <g> attribute transform is expecting a number but is instead receiving "scale(NaN) translate(N..."

Hey there! I'm currently working on creating a form with a map to select the country of birth using JVectorMap. However, when checking the Google Chrome developer console, I encountered the following error message: jquery-jvectormap-2.0.5.min.js:1 Err ...

How can I show the localStorage value in an HTML5 template using Angular2?

I have two keys stored in localStorage and I want to display one of them on my template. I'm having trouble accessing these values. I even created an interface specifically for storing the value of the currentUser key from localStorage. How should I g ...

Text in various styles is layered on top of an image, ensuring that text in one style does not overlap text in another style

Struggling with placing text over an image? Trying to achieve different text styles but ending up with overlapping lines? Here's a snippet of HTML that works with only one text style: <li style="" class="portfolio-content-CV"> <div class ...

creating a table displaying data in a horizontal format sourced from ajax/json transformation

I am currently working on a piece of code that retrieves a list of IDs from local storage and compares them to IDs in a JSON file. If there is a match, the corresponding data is displayed in a table. However, I am facing an issue with my table layout as i ...

What measures can I take to ensure that users cannot tamper with the PayPal code?

I've integrated a "Pay Now" button from Paypal onto my website. However, there is an issue where users can easily alter the payment amount before proceeding. Below is the code PayPal has provided: <form action="https://www.paypal.com/cgi-bin/webs ...

The selected Google Font Family remains unchanged

After taking a break, I decided to dive back into web development in order to create a simple webpage. My starting point is Bootstrap, and I am constructing my page based on that framework. However, I'm facing an issue with changing the font family of ...

What could be the reason for this tag showing up empty after being parsed with beautiful soup?

Currently utilizing beautiful soup to parse through this particular page: In an effort to retrieve the total revenue for 27/09/2014 (42,123,000) which is among the primary values at the top of the statement. Upon examining the element in chrome tools, it ...

Hover over the image to trigger animation effects

Looking for a way to enhance my current jQuery script that creates an orange transparent hover effect over images. How can I add animations, specifically a fade in and out effect? $(document).ready(function() { $('#gallery a').bind('mo ...

Different ways to generate DOM element using jQuery

When it comes to creating a new DOM element from JavaScript or jQuery code, there are numerous methods to consider. Some examples include: $('<div>').prop('id','someid').addClass('someclass'); $('<div& ...

What steps should be taken to populate a grid row if a certain div element is not present?

I am currently using tailwindcss and have this specific HTML code snippet: REPL: https://play.tailwindcss.com/L8McFjGBVC <div class="grid grid-cols-12"> <div class="col-span-4 bg-red-300">1</div> <div class=&qu ...

The table value is only updated once with the onclick event, but the updated value is not displayed when the event is clicked again

I am facing an issue with updating names in a table through a modal edit form. The first name update works perfectly, but the second update does not reflect in the table. I want every change made in the modal edit form to be instantly displayed in the tabl ...

Fixing the alignment of the left column table in Bootstrap 3.3.7

Is there a way to fix the left table column (date and all column names) in Bootstrap 3.3.7? I attempted to use position: fixed; but it didn't work as expected. Any suggestions on what I should do next? Check out this fiddle for reference <scr ...