Utilize CSS to vertically align buttons

One of my current projects involves creating a panel with buttons organized in columns side by side, similar to the layout shown below:

https://i.sstatic.net/ObAqw.png

However, I am struggling to achieve this desired arrangement.

Below is the code I have been working on:

<style>
* {
    box-sizing: border-box;
}
// More CSS styles here
<body>

<h2>Title</h2>


<div class="container">
  <form action="/action_page.php">
    // Form elements here
 </form>
</div>
<a href="1.html">1</a>
</body>

I suspect that the @media screen and .col-25/.col-75 statements in the CSS are causing some conflicts, but it's puzzling because they seem to only affect the spacing inside text areas, labels, and buttons, not outside of these elements.

UPDATE Upon further investigation, it appears that the mentioned CSS statements are not the root cause of the issue.

Answer №1

When working with a div, it is important to note that it is a block level element, which means any element placed inside it will typically be moved to the next line. However, you can utilize the CSS grid system in this scenario to define the number of columns you would like to have.

.button-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-gap: 10px;
}
<h2>Some title</h2>
<div class="container">
  <form action="/action_page.php">
    <div class="row">
      <div class="col-25">
        <label for="fname">key 1</label>
      </div>
      <div class="col-75">
        <input type="text" id="some" name="somethig" placeholder="some text">
      </div>
    </div>
    <div class="row">
      <div class="col-25">
        <label for="lname">key2</label>
      </div>
      <div class="col-75">
        <input type="text" id="some again" name="more something" placeholder="more text">
      </div>
    </div>

    <div class="button-container">
      <input type="submit" value="action 1">


      <input type="submit" value="action 2">

      <input type="submit" value="action 3">


      <input type="submit" value="action 4">


      <input type="submit" value="action 5">


      <input type="submit" value="action 6">
    </div>

  </form>
</div>
<a href="1.html">1</a>

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

Does Vuejs emit an event when a specific tab becomes active in boostrap-vue?

I am looking for a way to display and hide a section on my page when a specific tab is active, and close it when the tab is inactive. I have tried using the forceOpenSettings and forceCloseSettings methods for opening and closing the div. Is there an event ...

How to search for a value in Firebase database and save it to an HTML table?

I am working on fetching specific values from my 'snapshot' and storing them if they exist. Below is the snippet of my code: function paydata(){ firebase.database().ref("pay/0/0/").once('value', function(snapshot){ var resp ...

creating an HTML table from JSON data using a specific key

In this json file, I am looking to create separate tables based on the IDs provided. For example, ID: "50" should be displayed in one table, while ID: "57" should be shown in another table within the same context. { "version": "5.2", "user_type": ...

The art of analyzing HTML using either jquery or php

I have a question regarding HTML coding. Can anyone help me solve the following example? Here is a snippet of my HTML site: <div> <p><strong>Title 1</strong></p> <p>Content 1</p> <p>Content 2< ...

Proceed with the execution of the script after a successful completion of the jQuery AJAX request

I am facing a challenge with my click function that needs to open a popup window once the ajax call is successful. I have tried different solutions like setting async: false, placing the popup in the ajax call (which got blocked by the browser), and using ...

Tips for initiating a PHP class method through AJAX

As someone who is just starting to learn about ajax, I'm currently facing a challenge with calling the get_mother method through ajax in my form's textbox change event. My goal is to display the results in a datalist by using the following code. ...

What is the proper way to utilize BrowserRouter when child routes are connected to components?

I recently started learning React and decided to create a signup form following a tutorial on React Tutorial. However, the tutorial turned out to be outdated. I attempted to implement browser redirects for the signup, login, and home page links by defining ...

Why can my JavaScript server code read "2011" but not "20,11" when both are formatted as strings?

Currently, I am trying to establish a connection between Storm and JavaScript through redis. While the redis aspect of the connection is functioning correctly, I am encountering an issue when attempting to publish tuples (essentially Strings). Even though ...

Different parameters in an Angular filter pipe

Currently, I am facing a challenge in implementing multiple filters on a pipe for a search result page that retrieves data from an API. How can I integrate different parameters into this filter pipe successfully? Access the application here: https://stack ...

Firebase Admin refuses to initialize on a Next.js application that has been deployed on Firebase

Currently, I am facing an issue while attempting to deploy a Next JS app to Firebase hosting using the web framework option provided by firebase-tools. The problem arises when trying to initialize firebase-admin as it seems to never properly initialize whe ...

AngularJS $cookies version 1.6.9 experiencing functionality issues

I recently implemented AngularJS $cookies 1.6.9 in my website to handle cookie management. To test it out, I attempted a basic cookie set like this: $cookies.put('myCookieTest', 'test'); var cookie = $cookies.get('myCookieTest&apo ...

Spin a Material UI LinearProgress

I'm attempting to create a graph chart using Material UI with the LinearProgress component and adding some custom styling. My goal is to rotate it by 90deg. const BorderLinearProgressBottom = withStyles((theme) => ({ root: { height: 50, b ...

Tips on adding space between a material icon and its corresponding description

I have a design that needs some adjustments. The material icon is too close to the description, and I attempted to create padding by adding the following CSS: .location-secondary-info span:first-child { padding-right: 5px; } However, this change did no ...

What is the best method for rounding a decimal number to two decimal places?

Here is the JavaScript code I am using: $("input[name='AuthorizedAmount'], input[name='LessLaborToDate']").change(function () { var sum = parseFloat($("input[name='AuthorizedAmount']").val()).toFixed( ...

kineticjs equivalent to jquery sortable

Could someone recommend a kineticjs plugin or script that works with jquery's "sortable" function? I am trying to create a list of shapes where I can drag and drop them, and when one element moves, the other elements shift into place. ...

Save Bson query as a Javascript log

When working with Java to create a complex MongoDB query, I often log the query before executing it: log.info("Filter: {}", queryFilter); The logged query output typically looks like this: And Filter{filters=[Filter{fieldName='FinInstrmGnlAttrbts.C ...

What is the most effective method for populating data within a browser window?

I have a list of files stored in $scope.data that I retrieved from the searchFactory. Now, my goal is to display these files in the browser window. How can I accomplish this task? ctrl.js $scope.displayFiles = function (){ $window.open($scope.dat ...

Creating a dynamic display of flash files on a webpage through a unique combination of PHP, AJAX, and

Despite my lack of experience with Ajax and minimal java knowledge, I have a strong background in SQL and PHP. Even though I anticipate criticism for this question, I am determined to seek help. My primary objective is to rotate 4 flash SWF files randomly ...

ReactForms Deprication for NgModel

According to Angular, certain directives and features are considered deprecated and could potentially be removed in upcoming versions. In a hypothetical scenario, let's say I am using NgModel with reactive forms, which Angular has marked as deprecate ...

Slide in parts gradually by scrolling up and down, avoiding sudden appearance all at once

I have implemented a slider on my website using jQuery functions. For scrolling down, the following code snippet is used: jQuery("#downClick").click(function() { jQuery("html, body").animate({ scrollTop: jQuery(document).height() }, "slow"); ...