Is there a way to ensure the alignment of items remains consistent, especially for the rightmost column, by enclosing them within a div element?

I'm currently working with Vue.js and using a UI component framework designed for it. I'm facing an issue where aligning numbers like 500 or 5000, as well as icons, is proving to be difficult. The numbers in the rightmost column need to be aligned properly, so I tried wrapping them in a div. However, I still can't get it to work correctly. Can anyone provide guidance on how to resolve this?https://i.stack.imgur.com/GspBg.png

<v-list-item
  v-for="result in results"
  :key="result.id"
  class="grey lighten-3 mb-1"
>
  <v-list-item-content class="my-1 px-2">
    <v-list-item-title>
      {{ $datetime(new Date(result.timestamp * 1000)) }}
    </v-list-item-title>
  </v-list-item-content>
  <div>
    <v-list-item-content
      v-if="$vuetify.breakpoint.smAndUp"
      class="my-1 px-2"
    >
      <v-list-item-title>
        {{ $n(result.used) }}
        <v-icon size="20">
          mdi-arrow-right-bold
        </v-icon>
      </v-list-item-title>
    </v-list-item-content>
  </div>
  <div>
    <v-list-item-content class="my-1 px-2">
      <v-list-item-title>
        {{ $n(result.point) }}
      </v-list-item-title>
    </v-list-item-content>
  </div>
</v-list-item>

Answer №1

Check out this innovative method that utilizes subgrid to perfectly align items within deeply nested elements. Give it a try and see how effective it can be.

.entries {
  display: grid;
  grid-template-columns: 1fr repeat(3, auto);
  grid-auto-flow: row;
  gap: 10px;
}

.entry {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
  align-items: center;
  background-color: #ccc;
  padding: 10px;
}

.before {
  justify-self: end;
}

/* if you need to align right most numbers to the right, uncomment this
.after {
  justify-self: end;
}
*/
<div class="entries">
  <div class="entry">
    <time>2024-04-17 12:12:23</time>
    <div class="before">500</div>
    <div class="arrow">👉🏻</div>
    <div class="after">5,000</div>
  </div>
  <div class="entry">
    <time>2024-04-17 12:13:23</time>
    <div class="before">500</div>
    <div class="arrow">👉🏻</div>
    <div class="after">5,000,000</div>
  </div>
  <div class="entry">
    <time>2024-04-17 12:14:23</time>
    <div class="before">500,000,000</div>
    <div class="arrow">👉🏻</div>
    <div class="after">500</div>
  </div>
  <div class="entry">
    <time>2024-04-17 12:15:23</time>
    <div class="before">500,000</div>
    <div class="arrow">👉🏻</div>
    <div class="after">1,500,000,000</div>
  </div>
</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

Unable to set up service worker with Workbox window

I need help migrating from v3 to v4 in my Vue.js app. I am using workbox-window (CDN) and workbox-webpack-plugin for this task. While everything works fine locally with an http-server, I encounter an error after deployment that prevents the service worker ...

What advantages does separating vendors bring to Laravel Mix?

My initial bundle size was 246kb, and I wanted to reduce it further. After researching, I came across the method of extracting Vue and jQuery using mix.extract(['vue', 'jquery']);. Implementing this in my webpack.mix.js file resulted in ...

Enhance the appearance of your Vuejs application with conditional style formatting

I want to enhance a basic table by applying conditional CSS styles to the cells based on their values. For example: If area1 == 'one', then assign the td-one CSS style. <tr v-for="version in versions" :key="version.id"> < ...

Adjusting a Form Input Field

There seems to be an issue with the text alignment in my submission form input field, as the text appears a few pixels too low. This is causing certain letters like y, q, and j to bleed below the box in Chrome and only partially show in IE 8. To fix this p ...

Enhancing CSS compatibility for Internet Explorer 9 with CSS3

I need to create a Jagged Edge border without relying on an image, and I want it to be compatible with IE9 and newer versions. Currently, it works in most browsers but not in IE9. Any suggestions or advice would be greatly appreciated. Thank you! Below is ...

After the main page is loaded, the div will be dynamically populated with HTML content. How can we confirm that it has finished

I recently took over a project where a page loads and then code attached to that page populates a div with dynamically generated html – essentially filling an existing div with a string of html elements. Within this string are links to images, among oth ...

Creating visually appealing Jquery-ui tab designs

Trying to customize the jquery tabs, I experimented with styling them to my liking. One thing I did was attempt to reduce the size of the tabs by adding a height:45px; to the UI stylesheet shown below. .ui-tabs-vertical .ui-tabs-nav li { clear: left; ...

Issue with CSS Reset code causing disruption for one hyperlink

Check out the menu at this link: http://fiddle.jshell.net/V88c6/8/show/ To view the complete jsfiddle, click here: http://jsfiddle.net/V88c6/8/ Here is the HTML code: <div id="head_1"> <div class="inner"> <div class="column ...

Ensuring a full height div using CSS

I have encountered an issue and created a fiddle to help illustrate it: http://jsfiddle.net/XJpGT/ The challenge I am facing is ensuring that the height of the green box always remains at 100%, while also making sure that the green and orange boxes do not ...

How to Maintain SASS Code Efficiency with Media Queries

How can I avoid repeating myself in my CSS code when using two different media queries for phones and tablets that require the same exact styling? $mobile-portrait: "only screen and (max-width: 680px)"; $tablet-portrait: "only screen and (min-device-wid ...

Tips for Choosing the Right Objects in Vue.js

I have the following code that combines all objects in a person and stores them in an array called Cash:[] this.cash = person.userinvoice.concat(person.usercashfloat) Inside person.usercashfloat, there is an element called validate which sometimes equals ...

If there are multiple Monaco diff editors present on a single page, only the first instance will display the diff

I'm currently working with a Vue component that renders a diff editor using Monaco. However, when I have more than one instance of this component on the same page, only the first one displays the diff highlights. Here is the template: <template> ...

Placing a button at the bottom of a bootstrap well

Hey there, I'm facing an issue with the button positioning. I really need the button to be placed at the bottom of the well, but for some reason, it keeps showing up next to the image instead. This is what's happening: the button is ending up be ...

VueJS: Unable to access the 'name' property as it is undefined"

I'm at a loss trying to figure out a solution for this issue. My current task involves editing a pub schedule using an edit form: pubs/UpdateProfile.vue <template> <confirm title="Edit Pub" ok="Save pub" :show="show" v-on:save="sa ...

Troubleshooting the issue with a styled subcomponent in React using Styled Components

Recently, I've delved into React and have been experimenting with creating a Modal component using styled components. My goal is to achieve a similar effect to Framer Motion's motion.div, but utilizing styled components instead. Currently, I hav ...

Text Fade-in Animation with CSS 3

Could someone assist me in creating an animation similar to a marquee using CSS "animation" and "keyframes"? I attempted to move text from top to bottom, but encountered an issue where the text would only restart its movement from the top once it reached ...

Place the border image underneath the div element

I successfully added a border image to the right side of my div, but now I want it to extend slightly below the div. Is there a way to increase the height of the border image? Or should I just float the image next to the div and how would I go about doing ...

Divs aligned horizontally with automatic height

I am facing a dilemma with two child divs placed side by side within a parent div. The height of each div is generated based on the viewport-size, making it unknown. The issue arises in the left div where an image needs to be resized to match the height o ...

Retrieve a pair of columns from the database by utilizing SQLalchemy

Currently, I am delving into Python and endeavoring to generate a drop-down menu within my form by utilizing data from another table. Here is the code snippet I have been working on: In my Models.py file: class empmasterModel(db.Model): __tablename__ ...

Tips for globally overriding MUIv4 class in JSS for nested themes

Summary: Skip to EDIT2 MUIv4 has generated the following classes for me based on my nested theming: <label class="MuiFormLabel-root-121 MuiInputLabel-root-113 MuiInputLabel-formControl-115 MuiInputLabel-animated-118 MuiInputLabel-shrink-117 M ...