Displaying inner words in an array vertically using Vue JS

I'm facing an issue with the positioning of time elements in my array on the browser. They are currently located at the bottom, but I need them to be displayed on the sides. I attempted to solve this problem using CSS, but without success. Then, I tried incorporating HTML tags inside the array elements, such as

<span> 12:32 </span> <span> AM </span>
, and specifying display: flex for the <li> elements. However, this approach also did not work out as expected.

For reference, you can view the code on codesandbox.

<template>
  <div class="time-container">
    <div class="Container Flipped">
      <div class="Content">
        <ul>
          <li v-for="(item, index) in time" v-bind:key="index">
            {{ item }}
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>

export default {
  data() {
    return {
      time: ["10:00 AM", "10:30 AM", "11:00 AM", "11:30 AM", "12:00 PM", "12:30 PM", "1:00 PM", "1:30 PM", "2:00 PM", "2:30 PM", "3:00 PM", "3:30 PM", "4:00 PM", "4:30 PM", "5:00 PM", "5:30 PM", "6:00 PM", "6:30 PM", "7:00 PM", "7:30 PM", "8:00 PM", "8:30 PM", "9:00 PM", "9:30 PM", "10:00 PM", "10:30 PM", "11:00 PM", "11:30 PM", "12:00 AM", "12:30 AM", "1:00 AM", "1:30 AM", "2:00 AM", "2:30 AM", "3:00 AM", "3:30 AM", "4:00 AM", "4:30 AM", "5:00 AM", "5:30 AM",
        "6:00 AM", "6:30 AM", "7:00 AM", "7:30 AM", "8:00 AM", "8:30 AM", "9:00 AM", "9:30 AM",],
    }
  }
}
</script>

<style scoped>

@font-face {
  src: url(~@/assets/fonts/FontsForClosePage/Montserrat-Bold.ttf);
  font-family: 'Second-Montserrat-Bold'
}

.Container {
  overflow-y: auto;
}

.Flipped, .Flipped .Content
{
  transform:rotateX(180deg);
  -ms-transform:rotateX(180deg); /* IE 9 */
  -webkit-transform:rotateX(180deg); /* Safari and Chrome */
}

.time-container {
  padding: 10px;
  background: #74C8C5;
  overflow-y: auto;
}

ul {
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0;
}

li {
  background: #FFFFFF;
  margin-right: 8px;
  border-radius: 7px;
  list-style-type: none;
  padding: 5px 10px 5px 10px;
  font-family: 'Second-Montserrat-Bold';
  font-size: 12px;
  line-height: 16px;
  text-align: center;
  color: #000000;
}
</style>

Answer №1

To fix this issue, simply include the white-space property in your li selector:

li {
  white-space: no-wrap;
}

Keep in mind that as your list grows, you may encounter other challenges - Why don't flex items shrink past content size?. For more information on flexbox and text truncation, check out this resource.

Answer №2

After experimenting with numerous options, I finally found success with this particular solution.

li {
  min-width:70px; 
}

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 responseText array is encountering parsing issues

Utilizing ajax, I am retrieving a json_encoded array from my PHP parser. The responseText returned is ["4.wav","2.wav","3.wav","6.mp3","1.mp3","5.wav"] If I place this into an array like so: var myArray = ["4.wav","2.wav","3.wav","6.mp3","1.mp3","5.wav" ...

The text entered in the textbox vanishes after I press the submit button

When a user selects a value in a textbox and clicks the submit button, the selected value disappears. <div class="panel-body" ng-repeat="patient in $ctrl.patient | filter:$ctrl.mrd"> <form> <div class="form-group"> ...

Updating the Document Object Model

React re-renders only when there is a change in state. However, it may seem like the changes made directly to the real DOM reflect instantly. This might raise questions as to what triggers the re-render when the state remains unchanged. import React from ...

What is the correct way to bind pairs (arrays of tuples or multidimensional arrays) in SQLAlchemy?

Can you show me an example of constructing a MySQL query with SQLAlchemy? SELECT * FROM table WHERE (key->>"$.k1", key->>"$.k2") IN ((1, "string1"), (2, "string2")) I attempted to use the text method but encountered an issue: select([table.c ...

Creating personalized validations for input fields in Vuejs2 using vee-validation

Hello there! I have a query regarding my code. I have input fields for firstname, lastname, and middlename, and I want to use a single method to throw an error for all these fields. The issue I'm facing is that I can only pass one field ...

JavaScript if statement can be used to evaluate two variables that have the same values

I am currently working on a Wordle-style game with a 6x6 grid. I'm sending the row as an array through a socket, and while I can check if a letter is correct, I'm having trouble with identifying duplicates that are in the wrong position. I iterat ...

What can I do to stop a webpage from automatically refreshing when I submit a form?

I'm currently in the process of building my very first website, and I've run into a bit of a snag that I can't seem to figure out. Whenever a user tries to add an item to the cart or increase the quantity, I want to avoid the page refreshing ...

Understanding the impact of event loop blocking and the power of asynchronous programming in Node JS

I am new to Node.js programming and I really want to grasp the core concepts and best practices thoroughly. From what I understand, Node.js has non-blocking I/O which allows disk and other operations to run asynchronously while JavaScript runs in a single ...

Incorporating a classList.toggle into a snippet of code

button, p, h1, h2, h3, h4, h5, a{ /* Define specific elements to use "fantasy" font */ font-family: Tahoma; } #main_body{ margin: 0px auto; background-color: #dedede; } #top_body{ /* Remove margin for simplicity */ } #t ...

transmitting information using dataURL

Hey there! So I've got this code that does a neat little trick - it sends a dataURL to PHP and saves it on the server. In my JS: function addFormText(){ $('body').append('<input type="hidden" name="img_val" id="img_val" value="" /& ...

As soon as a key is pressed in tinyMCE, the tracking continues until reaching the conclusion of the initial <

I am attempting to capture, in real-time, the user input in the .content textarea and paste it into the .intro. I have tried the following code without success: //This code is specifically for tinymce, as I am using tinyMCE as a rich text editor for textb ...

The property being set in Angular is undefined, causing an error

I am struggling to understand why the code below is not functioning as intended: Main.html <div class="MainCtrl"> <h1>{{message.test}}</h1> </div> Main.js angular.module('myApp') .controller('MainCtrl', f ...

Dependency management in ReactJS components

I am grappling with the optimal structure for a React component that is composed of other components. Let's look at the first example: <ColorSelect id="color" label={this.state.selectLabel} trigger={{ color: "lime", text: "Lime"}} onPropagateCli ...

Retrieving the variable value instead of a reference using Ajax in ASP

After spending nearly two days trying to figure out this code and researching every possible solution, I still haven't been able to get it to work properly. It's likely that I'm implementing it incorrectly or missing something, so I've ...

The functionality of multiple if conditions is malfunctioning

Displayed below is an array with two key-value pairs: Array ([web_tokens] => ft2TxdXhon8,fYTsgCoCrBY [phone_tokens] => c-hqzdEjs2M,dWahJ8MOfXY, dkYoMgoPNN8) The issue arises when attempting to retrieve them separately within an if statement; ...

Tips for changing the text in a .txt file that has been accessed through a $.get request

Is there a way to read and open a file, but update a specific value within it? For example, if my data.txt looks like: [ {"slot": "1", "name": "Bob"}, {"slot": "2", "name": "John"} ] and I want to update it with a query like: "UPDATE data.txt SET na ...

Excellent JavaScript library for capturing screenshots of the entire screen

Is there a good JavaScript library that enables users to take a screenshot of a webpage and customize the size before saving it to their computer? I am specifically looking for a pure JS solution where users can simply click on a button and have a "save a ...

What is the best way to send data from a React.js application to AWS Lambda?

I'm having trouble sending data from my React application to an AWS Lambda function through API Gateway. Here is the code snippet from my React app: const exampleObj = { firstName: 'Test', lastName: 'Person' }; fetch(process.env.R ...

What is the best method for animating a display table to none or reducing its height to

My goal is to animate a header whenever the class collapseTest is applied. After some trial and error, I have come up with the following solution: http://jsfiddle.net/robertrozas/atuyLtL0/1/. A big shoutout to @Hackerman for helping me get it to work. The ...

No preflight request was sent from the Vue production app to the server, leaving no options available

I have a vue app deployed statically. It makes requests to a server that is hosted on another url. Whenever the vue app tries to make API requests, CORS errors pop up: Access to XMLHttpRequest at 'https://ALB_URL' from origin 'HTTPS://APIG ...