Creating space between flex column components

I am attempting to create some space between the buttons (Reset Filter/Apply Filter/Save & Apply Filter) in my UI. I have used flexbox to align the buttons, but I am struggling to add margins or gaps between them. Any suggestions on how to achieve this?

Here is the code snippet:

<div class="d-flex flex-column justify-space-around">
    <v-btn
        text
        style="margin-left: 30px"
        color="primary"
        @click="resetFilter()">
        Reset Filter
    </v-btn>
    <v-btn
        v-if="!updatingSavedFilter"
        color="primary"
        @click="
        applyFilter()
        filterDropdownOpen = false">
        Apply Filter
    </v-btn>
    <v-btn
        color="primary"
        @click="
        validateAndSaveFilter()    
        filterDropdownOpen = "false">
        Save &amp; Apply Filter
    </v-btn>
</div>

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

Answer №1

Are you utilizing Vuetify? If so, consider applying a margin class to each button:

<v-btn
   text
   style="margin-left: 30px"
   color="primary"
   class="mb-2"
   @click="resetFilter"
>
   Reset Filter
</v-btn>

Take a look at Vuetify's spacing guidelines.

On a separate note: refrain from using inline styles. It's recommended to use classes instead. For example:

class="mb-2 ml-7"

This will result in an 8px bottom margin and a 28px left margin.

Additionally, when assigning a function name to @click, do not execute it, simply pass the name (refer to the example above).

Answer №2

To utilize justify-content: space-around, a specific height must be set as shown in the following example:

.box {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  height: 300px;
}

.box button {
  height: 50px;
  width: 200px;
}
<div class='box'>
  <button>Button</button>
  <button>Button</button>
  <button>Button</button>
</div>

Alternatively, you can make use of the latest gap property.

.box {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  gap: 20px;
}

.box button {
  height: 50px;
  width: 200px;
}
<div class='box'>
  <button>Button</button>
  <button>Button</button>
  <button>Button</button>
</div>

Another option is to simply define a margin-top.

.box {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
}

.box button {
  height: 50px;
  width: 200px;
}

.box button:not(:first-child) {
  margin-top: 20px;
}
<div class='box'>
  <button>Button</button>
  <button>Button</button>
  <button>Button</button>
</div>

Answer №3

One simple way to create space between flex items without individually styling each child element is by using this universal CSS solution:

.d-flex{
  gap: 10px;
  gap: 10px 20px; /* specifies row-gap and column gap */
  row-gap: 10px; /* applies only to rows */
  column-gap: 20px; /* applies only to columns */
}

For more information, you can visit: https://css-tricks.com/snippets/css/a-guide-to-flexbox/#flexbox-background

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

Troubleshooting recursive function errors in a Javascript menu

//check out this current jsfiddle for more details: http://jsfiddle.net/0ht35rpb/45/ I'm attempting to create a loop through a JSON navigation tree in order to match the alternative language counterpart when a user navigates to a specific page. //H ...

How can we accurately identify the server that initiated an AJAX call in a secure manner?

Imagine a scenario where Site A embeds a JavaScript file from Server B and then makes a JSONP or AJAX request to a resource on Server B. Is there any foolproof way for Server B to determine that the specific JSONP request originated from a user on Site A, ...

Developing an Interactive Quiz using jQuery

Looking for a quiz example created using jQuery but without needing server-side processing for the results. The result should be displayed instantly after answering all the questions! :) ...

iOS button on mobile Safari in the down state

Is there a way to customize the appearance of buttons in Mobile Safari so that they show my specified "down" (:active) state instead of the default semitransparent overlay when touched? ...

Having trouble extracting the selected date from a datetimepicker to pass it via AJAX

The datetimepicker on my webpage is structured like this: <table class="table borderless" id="schedule_time"> <tbody> <tr> <td align="center"> <div id="timepicker" class="form-group" style="width:30%"> ...

Unable to host Express app on Firebase functions emulator due to a port conflict with error code EADDRINUSE: address already in use :::3000

Testing the deployment of an express app on Firebase using Firebase functions has presented a challenge for me. Upon running the command firebase serve, I encountered the error EADDRINUSE: address already in use :::3000. Below is my index.js file: const fu ...

Regular expressions for identifying a pattern that is not enclosed within double quotation marks

There is a specific string I need to analyze: FIND files where file2=29 AND file32="12" OR file623134="file23" A user inputs this text in order to conduct a search within their data. The application then converts this text into an SQL Query. For instanc ...

Find the sum of object prototype differences in JavaScript

Struggling with a JavaScript challenge - I need help creating a JavaScript script where the user inputs the month and the amount of rain for that month, and the program generates a table showing the total rain for each repeated month. For example, if Janua ...

Managing numerous HTTP requests and providing the outcome through Angular and Rxjs

Currently, I am facing a challenge with sending GET requests for a large number of URLs (50 of them) to the Spotify server and then returning their results in a single Observable/array/object. This is the code snippet I have come up with: curatedTopArti ...

Efficient two-way communication with Sanic websockets without endlessly waiting

I had previously inquired about websockets in Sanic through this question and this one. This is a follow-up to those discussions. The code below allows me to send broadcast messages to my websocket clients: import asyncio from sanic import Sanic, respons ...

Nextjs: issue with updating state within an interval is not functioning

This is my current situation: const [time, setTime] = useState(10) And this is the function I'm using: const runTimer = () => { useEffect(() => { const interval = setInterval(() => { console.log(time) if ( ...

Upon clicking a button on page 1, the data is transmitted to page 2 before redirecting the user to page 3

When a user enters information into a text field on page1.php and clicks the submit button, the data is sent to page2.php where it is used to query a database and save it in an XML file. <Form name="search_form" method="POST" action="page2.php"> ...

Conic-Gradient causing an intriguing visual anomaly

When attempting to create a simple conic-gradient using CSS, I've noticed a peculiar horizontal line that keeps appearing. These lines seem unpredictable and sometimes disappear when the window is resized. div { width: 101.5px; height: 10 ...

Issue: Unidentified supplier following JavaScript compression

Here is the AngularJS controller code that I am working with: (function() { 'use strict'; angular .module('app') .controller('TemplateCtrl', TemplateCtrl); function TemplateCtrl($http, $auth, $rootS ...

Utilize mapGetter and mapMutations in Vuex with TypeScript without the need for class-style components syntax

After completing a project in Vue, I found myself getting a bit confused without static types. To address this, I decided to incorporate TypeScript into my project while still maintaining the traditional way of writing code, without classes and decorators. ...

Combine two arrays into a single array object

I have an item containing the following data: "Item": { "data1": [], "data2": [ "5", "6", "7", "8" ] } Upon inspecting my item, I noticed that it consists of two sections. This is understandable since there ar ...

What are some ways I can personalize my react-table components?

I want to customize the functionalities with unique layouts and positioning. Instead of using the default next and previous buttons, I prefer creating my own. Is there a way to achieve this without directly modifying the code in node_modules directory? ...

CSS - The 'object-fit: cover' attribute isn't functioning properly within the HTML email content

Could you please assist me with my html email body issue regarding the "object-fit: cover;" parameter? It works perfectly when displayed on the web, but is not functioning correctly in an html email body. EmailProvider: New Outlook in WIN PC Mobile: Also ...

AngularJS refrains from computing expressions

As a newcomer to AngularJS, I decided to experiment with some basic code. However, the results were not as expected. Here is the HTML code that I used: <!DOCTYPE html> <html ng-app> <head> <script src="js/angular.min.js"></sc ...

Using Three.js WebGL to create a custom circle with unique fill and border colors generated from a shader

Currently, I am utilizing Three.js alongside the WebGLRenderer. I am exploring ways or searching for an example on how to create circles using CircleGeometry and have the ability to manipulate their fill and border color through a vertex or fragment shad ...