What is the best way to use CSS to evenly lay out a group of dynamically generated buttons?

My Vue-generated buttons need to be evenly laid out on the bottom of the page, with equal space on the left and right. The mdui button style I am using has fixed width and height, so I have to decide between a single row for fewer buttons (less than three or four) or two rows for more buttons (exceeding the mobile page's width).

I attempted using

<div class="bottomBtn" style="display:flex; flex-wrap:wrap;">
but it did not work as expected. I find div boxes confusing. How can I achieve the desired layout?

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

My goal is to have the buttons evenly spaced on the bottom, but currently, they are all left-aligned as shown in the image.

<div class="bottomBtn">
<button class="mdui-btn mdui-btn-raised">Save</button>
<button class="mdui-btn mdui-btn-raised" v-if="pullDisplay">PullBack</button>
<button class="mdui-btn mdui-btn-raised" v-if="cancelDisplay">Cancel</button>
<button class="mdui-btn mdui-btn-raised" v-if="reviseDisplay">Revise</button>
<button class="mdui-btn mdui-btn-raised" v-if="sendDisplay">SendBack</button>
<button class="mdui-btn mdui-btn-raised" v-if="approvalDisplay">Approval</button>
</div>

Answer №1

To achieve this layout using flexbox, you can set the justify-content property to space-between.

For example:

<div class="bottomBtn" style="display:flex; flex-wrap:wrap; justify-content: space-between;">

I would suggest creating a class for these styles that can be applied to the div.

You could also experiment with using space-around or space-evenly for a similar effect to see which one works best for your design preferences.

If you need more guidance on using flexbox effectively, I recommend checking out this helpful guide.

And if you want consistent spacing between the buttons, simply adding left and right margins to the buttons should do the trick when using flexbox.

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

Updating div visibility based on form content in PHP

I am struggling to find a way to filter a page filled with divs based on form input to determine whether they should be displayed or not. The layout is akin to a collection of articles, where each div showcases an image and some text that links to the comp ...

Challenges with Vuex and updating arrays using axios

I am currently facing a challenge with VueJS Vuex and Axios: The issue arises when I retrieve an array with Axios and loop through it to populate its children this way: "Rubriques" has many self-relations, so one rubrique can have multiple child rubriques ...

Using an HTML ellipsis without setting a specific width

I am working on achieving a specific layout as shown in the screenshot below. If both SPAN and B fit within the box, they should be displayed one after another. If they do not fit, SPAN should have an ellipsis while B is fully displayed (never larger tha ...

Navigating within components using code is an essential skill when working with Vue Router

I am currently developing a Quasar application powered by Vue 3 with vue-router version 4 All my routes are properly configured and function well when navigating from a component template using <router-link to="/route">Go to route</rout ...

It's essential to ensure that this property remains responsive, whether through the data option or by initializing the property for class-based components

This code snippet contains the template and path information. <template> <div class=""> <c1 :text="message1"></c1> <c1 :text="message2"></c1> </div> </templa ...

Adjust the width of the <td> elements that are nested under <th> elements with a specified

I want to define the width of the td elements in the tbody section under a thead element with colspan="2" using specific column widths in %. I need the table to maintain a fixed width without dynamically adjusting based on content. .sample { width: 10 ...

Preventing Vue.js SPA from accessing cached version when JWT expires: the solution

I'm encountering an issue with my Vue.js / Express application that I can't seem to resolve. Here's how the process unfolds: An unauthenticated user logs into the app and is presented with the login page. Once successfully authenticated, t ...

The element in Vue 3 Unit Test is proving difficult to access

I am currently working on a Vue 3 project that utilizes PrimeVue. Within my template, I have integrated a PrimeVue dialog component as shown below: <template> <div> <Button data-testid="showButton" label="Show" @cli ...

Transitioning from feelings to sewing: incorporate a duo of properties within variations and breakpoints

I was thinking about how to convert this styled-emotion code into stitches. Essentially, I need to handle the onlyShowOnDesktop and breakpoint props. The definition of breakpoint is as follows: const breakpoint = isTopNavigationBreakPoint ? theme.defaultB ...

Resetting several sticky titles after displaying and hiding elements

Inspired by a popular codepen example, I have successfully implemented sticky titles in my sidebar. However, when integrating these sticky titles with the functionality to show/hide related items on click, I encountered some unexpected issues. The code sni ...

Hover to reveal stunning visuals

Can anyone help me figure out how to change the color of an image when hovered over using HTML or CSS? I have a set of social network icons that I want to incorporate into my website, and I'd like the icon colors to change when the mouse moves over th ...

Achieving Full Height for Parallel Columns Divs with Bootstrap - A How-To Guide

I am struggling with getting two divs in parallel to have full height. Even though I have the divs side by side, when I try to set their height:100%;, nothing happens. What CSS properties do I need to modify to achieve this? The goal is to create a cove ...

Update background to full screen and include text when hovering over DIV

Currently, I am utilizing Bootstrap and have a layout with 6 columns containing icons/text within. I desire to implement a hover effect where each column triggers a background change in transition for the entire section. In addition, text and button elemen ...

Displaying content conditionally - reveal a div based on user selection

I have a dropdown menu and need to determine whether to display a specific div using the value selected via v-if. <select class="custom-select custom-select-sm" id="lang"> <option value="1">English</option> <option value="2">Sv ...

How to style tags between select options in HTML using React JS?

Is there a way to customize the appearance of a span element that is nested within an option tag? <select> <option value="option1">Active Wallet <span style={{fontWeight:'bold!important'}}>mBTC</span></o ...

It appears that the size of the textlabel in the HTML is not responsive to

When working with my HTML code, I've encountered an issue where I am unable to modify the height and width of a label using CSS. However, I have found that I am able to adjust the top and left positioning. HTML: <div id="loginname"> <l ...

Cannot close the Bootstrap dropdown after selecting an option

I am encountering an issue with a dropdown list that has a select feature using Bootstrap 3.4.1. The problem is that the dropdown remains open after selection and does not close unless I click outside of the list. Here is the HTML code: <div id="c ...

Is it possible to combine jQuery Mobile with Vue.js in a project?

Exploring new web technologies can be quite challenging, especially when it comes to making them work on mobile devices. I found AngularJS particularly tricky in this regard. I'm considering trying Vue.js along with some jQuery mobile elements instead ...

Exploring the secure synergy between Laravel 5.5 Passport client_secret and Vue JS authentication

Greetings to all, Currently, I am delving into the world of Laravel Passport and Vue.JS (standalone) simultaneously. In my authentication process, I am utilizing the Password Grant Token. An issue that has come up is the necessity for keeping the secret_ ...

Enhancing Tapestry Grid component column sort icons

In the Tapestry Grid components, the default column sort icons are blue and white, but if your page has a different color scheme, you may want to personalize them. How can you replace the default Tapestry Grid column sort icons with your own custom icons? ...