What methods can I use to ensure that the columns and rows in Vue are of the same size and length

Upon examining the image, it's clear that none of the columns and rows align properly and are all varying sizes. I am relatively new to JavaScript and Vue, so any assistance would be greatly appreciated. As far as my understanding from online resources goes, the v-row should automatically adjust the row and the v-col based on the number of elements within v-col, but it doesn't seem to work as intended. Am I missing something here?

<template>
  <div class="calculator">
    <v-container>
      <v-layout row >
          <div class="display">10</div>
        <v-col>
          <v-btn class = "btn">c</v-btn>
          <v-btn class = "btn">+/-</v-btn>
          <v-btn class = "btn">%</v-btn>
          <v-btn class = "operator">÷</v-btn> 
        </v-col>

        <v-col>
          <div></div>
          <v-btn class = "btn">7</v-btn>
          <v-btn class = "btn">8</v-btn>
          <v-btn class = "btn">9</v-btn>
          <v-btn class = "operator">x</v-btn>
        </v-col>

        <v-col>
          <div></div>
          <v-btn class = "btn">4</v-btn>
          <v-btn class = "btn">5</v-btn>
          <v-btn class = "btn">6</v-btn>
          <v-btn class = "operator">-</v-btn>
        </v-col>

        <v-col>
          <div></div>
          <v-btn class = "btn">1</v-btn>
          <v-btn class = "btn">2</v-btn>
          <v-btn class = "btn">3</v-btn>
          <v-btn class = "operator">+</v-btn>
        </v-col>

        <v-col>
          <div></div>
          <v-btn class = "btn zero">0</v-btn>
          <v-btn class = "btn">.</v-btn>
          <v-btn class = "operator">=</v-btn>
        </v-col>

      </v-layout>
    </v-container>
  </div>
</template>

<script>
export default{
}
</script>

<style scoped>
.calculator {
  display: grid;
  grid-template-columns: repeat(4,1fr);
  grid-auto-rows: minmax(50px,auto);
}

.display {
background-color:black;
grid-column: 1 / 5 ;
}

.zero {
  grid-column: 1 / 3;
  
}

.btn {
  font-size: large;
  color:black;
  background-color: rgb(236, 232, 232);
  border: 1px sold black;
}

.operator {
  font-size: large;
  background-color: orange;
  border: 1px sold black;
}
</style>

Answer №1

Ensure that your application is enclosed within the v-app component and the root element has an id app. This is a common reason for style issues.

If your code is in the App.vue file, try the following:

<div id="app">
 <v-app>
  <div class="calculator">
    <v-container>
      <v-layout row>
        <div class="display">10</div>
        <v-flex>
          <v-btn class="btn">c</v-btn>
          <v-btn class="btn">+/-</v-btn>
          <v-btn class="btn">%</v-btn>
          <v-btn class="operator">÷</v-btn>
        </v-flex>
        <v-flex>
          <div></div>
          <v-btn class="btn">7</v-btn>
          <v-btn class="btn">8</v-btn>
          <v-btn class="btn">9</v-btn>
          <v-btn class="operator">x</v-btn>
        </v-flex>

        <v-flex>
          <div></div>
          <v-btn class="btn">4</v-btn>
          <v-btn class="btn">5</v-btn>
          <v-btn class="btn">6</v-btn>
          <v-btn class="operator">-</v-btn>
        </v-flex>

        <v-flex>
          <div></div>
          <v-btn class="btn">1</v-btn>
          <v-btn class="btn">2</v-btn>
          <v-btn class="btn">3</v-btn>
          <v-btn class="operator">+</v-btn>
        </v-flex>

        <v-flex>
          <div></div>
          <v-btn class="btn zero">0</v-btn>
          <v-btn class="btn">.</v-btn>
          <v-btn class="operator">=</v-btn>
        </v-flex>
      </v-layout>
    </v-container>
  </div>
</v-app>
</div>

If this code is within a child component, ensure that your App.vue is wrapped correctly.

App.vue

<div id="app">
  <v-app>
    <ChildComponent />
  </v-app>
</div>

Tip:-
If this solution works, custom styling to create grid layouts may not be necessary. Vuetify will handle layout arrangements using rows and columns.

EDIT-

Replace v-col with v-flex since you are using Vuetify's first version.

Answer №2

Consider using this layout:

<div id="app">
    <v-app>
        <v-main>
            <v-container class="grey lighten-5">
                <v-row no-gutters>
                    <v-col cols="4" sm="4">
                        <v-card class="pa-2" outlined tile>
                            resuiltsd
                        </v-card>
                    </v-col>
                </v-row>

                ...

                <v-row no-gutters>
                    <v-col cols="4" sm="1">
                        <v-card class="pa-2" outlined tile>
                            One of
                        </v-card>
                    </v-col>
                </v-row>
            </v-container>
        </v-main>
    </v-app>
</div>

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

The background gently fades away, directing all attention to the popup form/element

After extensive searching, I have yet to find a straightforward solution that seems to be a standard practice on the web. My goal is to create a form that appears in the center of the screen when a button is clicked using CSS or jQuery. I would like the ...

Stopping man-in-the-middle breaches through user authentication in Node, Vue, and Passport

Currently, I am developing a web application using Node/Vuejs with Passport handling authentication. However, an issue has come to my attention regarding the security of my authentication setup. Essentially, my Vuex store is hitting a local API endpoint / ...

How to Toggle the "active" Class Among Child Elements in vueJS 2

I'm interested in learning how to implement this functionality using vue.js. Currently, I am able to toggle the active class on a single item, but when I click on another item, the active class remains on the previous item. Here is my current setup: ...

What causes the disparity in functionality between simple html and css in an Angular 2 project compared to a vanilla html website?

When incorporating the following html/css into a new Angular project created with Angular CLI using 'ng new ProjectName', I encountered issues. Despite adding the CSS to app.component.css or styles.css and the HTML to app.component.html, the Angu ...

display information in a structured table format

I am in need of HTML code that will render headers aligned above corresponding values when displayed. header1 header2 header3 List item 1 value111 value112 value113 value121 valueb122 valueb123 List item 2 value211 value212 value213 value221 valueb2 ...

Unusual positioning of submenus in CSS menus

I'm facing an issue with my menu where the last item "Apps" is supposed to stay in place instead of sliding down. I'm looking for a CSS-only solution to solve this problem. Here is my current CSS code: div.menu{ display: block; float: left; wi ...

What is the method for assigning a class name to a child element within a parent element?

<custom-img class="decrease-item" img-src="images/minus-green.svg" @click="event => callDecreaseItem(event, itemId)" /> Here we have the code snippet where an image component is being referenced. <template&g ...

Adjust the appearance of a specific element

When it comes to styling my HTML tags, I prefer a definitive approach. However, there is one particular tag that I want to exempt from this style choice. Is there a way to achieve this? ...

The CSS styles are not being completely applied to the PHP function

My current task involves dealing with multiple folders containing images. When a link is clicked on the previous page, a unique $_GET variable is sent and processed by an if statement, triggering a function to search for and display all pictures within the ...

Expanding borders occur when the element is repositioned using the translate property

I am trying to create a vertical line that remains in the center of a div container regardless of the screen size. I want this line to be 1px thick. However, when I use transform: translate(-50%, -50%);, the border seems to become thicker than expected. Be ...

Secure Socket Layer (SSL) certification for hosting an HTTP server on an

I am currently facing an issue with insecure SSL certificates within my project that consists of two main components: An ESP32 IoT device with a HTTPS server A VUE2 + Vuetify PWA web application deployed on Firebase hosting. Imagine a scenario where a c ...

Is it possible to modify @page directive(CSS) values from the code-behind(C#) or JavaScript?

Using the @page directive, you can define the printer margins for a page separately from regular CSS margins: <style type="text/css" media="print"> @page { size: auto; /* auto is the current printer page size */ margin ...

Unexpected behavior from flexbox layout

So I've been experimenting with Chrome lately. I created a div with display: -webkit-box;. Inside this div, there are 7 other divs all set to -webkit-box-flex: 1;. Oddly enough, the first div is smaller than the rest. Any ideas on why this might be ...

Ensuring fixed dimensions for divs (maintaining size irrespective of window width adjustments)

I'm struggling to find the right way to phrase my question, but I have a website example to help illustrate what I'm asking about. Check out this example website Upon resizing the browser window, only the margins of the website adjust and not t ...

Utilizing Javascript to extract data from a JSON file

I have a task involving importing a nested JSON file and the challenge is to extract specific data from the file and display it in a table format. Any tips on efficiently navigating through the different levels of the JSON file to access only the innermos ...

Getting the height of a div in a Nuxt.js application results in an error alert being displayed

Trying to retrieve the height of a div within a grid in a Nuxt application. <template> <div class="grid grid-cols-3"> <client-only> <Item v-for="( item, itemIndex ) in ItemsArray" ...

Is it possible to add a border to both the tbody and td

I currently have a table that is organized with tbody elements to group rows together. In order to create a grid-like structure, I applied borders to each individual td element within the tbody. However, I also desire to show that the tbodies themselves ar ...

How can I use CSS to ensure that both cards and images are equal in size?

I am currently utilizing react, with Material-ui being used for the Cards. For the layout, I have implemented CSS Grid Layout for the Grid system. Presently, the structure looks like this: https://i.stack.imgur.com/0FDyY.png However, my desired outcome i ...

Order the JavaScript object by its value if the keys are numerical

I'm currently working on a project using InertiaJS. I have a PHP array that I pass as a prop to Vue and display it as a select box. Here's what the object looks like in JavaScript: { 1: "Vexapa", 5: "Linga & Satro", ...

What steps should be taken to transform a dataframe into a string in order to resolve an issue and accurately display certain graphs?

I'm currently attempting to plot some graphs using the loop provided below: library(ggstatsplot) for (i in 5:ncol(df)) { print(ggbetweenstats(df, x = 'D', y = colnames(df[i]), palette = 'n ...