Addressing some minor visual inconsistencies in an HTML bullet-pointed list

After reviewing my current code, it is displaying the following:

https://i.stack.imgur.com/dvjrc.jpg

I am attempting to make the following changes:

  1. Ensuring each line in the list fits properly within its corresponding box by utilizing vertical-align: top.
  2. Shifting the 40 kcal and 30 kcal to the right side of the box using text-align: right.

However, I am facing difficulty in getting either of these changes to work as intended.


<template>
  <h3> Foods: </h3>
  <ul class="food-list">
    <li class="food-item">
      <p class="left">Banana &nbsp;</p>
      <p class="right">40 kcal</p>
    </li>
    <li class="food-item">
      <p class="left">Strawberry &nbsp;</p>
      <p class="right">30 kcal</p>
    </li>
  </ul>
</template>

<style scoped>
.food-list {
  width: 300px;
}

.food-item {
  height: 30px;
  width: 300px;
  display: inline-block;
  margin: -10px;
  border: solid 1px black;
}

.left {
  text-align: left;
  display: inline-block;
  vertical-align: top;
}

.right {
  text-align: right;
  display: inline-block;
  vertical-align: top;
}
</style>

If it helps, I am working with Vue + VueCLI for this project.

Answer №1

Avoiding separate styling for the left and right classes is possible by implementing

display: flex; justify-content: space-around;
on the food-item class. This will streamline your design process. Additionally, I find the use of margin: -10px confusing in that context.

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

Can you explain the purpose of using 'created' and 'activated' with keep-alive components in Vue.js?

At first, I am retrieving data from the api within the created hook and it is functioning perfectly. created() { this.fetchInformation() } While exploring best practices for lifecycle hooks, I stumbled upon this advice: You need to fetch some data f ...

Positioning a box at the bottom rather than at the top

I am on the lookout for a solution to shift/arrange divs to the bottom instead of the top. For example, when attempting to delete some of the divs with the "box" class in this code snippet: Current code: #hol ...

Employ jQuery for toggling CSS rotation

I have a plugin set up to handle the CSS3 attribute. It currently rotates 45 degrees when clicked, but doesn't rotate back when clicked again to hide the content. Any ideas on how to fix this? $("#faq dt").click(function() { $(this).next('dd ...

Integrating additional information (HTML) into current content utilizing Vue JS data structures

I am attempting to use Vue JS to load content onto a page. The user interface consists of a select element, a textarea, and a button. I want to display data from a third-party API response on the page. The first item loads successfully, but subsequent item ...

How to showcase an item appended to an array within a nested component using Vue.js

Working with Vue, I have a scenario where a component in my parent App.vue displays the contents of an array called ListofLists. When I push new data to this array, how can I ensure that the display list component reflects the updated data? In one of my c ...

An exception known as NullPointerException arises when attempting to invoke JDBC within a servlet

While running my RegistrationServlet, I encountered an issue when trying to create a Database object. Below is the servlet code snippet: @WebServlet("/register") public class RegistrationServlet extends HttpServlet { private static final long serial ...

Looking for CSS templates for improving your business web apps?

Many CSS templates out there are fixed-width, typically around 900 pixels wide... Right now, I'm in the process of creating an intranet Rails application and I'm seeking a good resource for CSS templates designed specifically for business applic ...

Updating the color of a v-chip in vuetify dynamically

Just starting out with vuejs and vuetify. I recently watched a tutorial on vuetify on YouTube, where the instructor set the color of v-chip in this way. <v-flex xs2 sm4 md2> <div class="right"> <v-chip ...

The footer is displaying unusual white space beneath it

Recently, I attempted to create a sticky footer using Flexboxes and the <Grid container> Check out the code on Codesandbox However, an issue arose - there was a strange whitespace below the footer. After some experimentation, I discovered that the ...

Sliding the container with a width adjustment and left margin fails to display all images

In the provided HTML code below, there is a functionality to move images horizontally by clicking on buttons: $(document).ready(function() { calculate_width(); $('#moveleft').click(function() { var loga = $('#marki #loga'); ...

Avoid placing the label within a form-inline in Bootstrap to maintain proper formatting and alignment

I am working on a form where I have two fields inline within a form-inline div. I am looking to move the labels of these fields above them rather than next to them. How can I achieve this without affecting the layout of the fields? Here is a CodePen link ...

Tips for making a table have the same width as its child td elements and enabling the table to exceed the width of the viewport

I am facing a challenge with a table that has dynamically changing rows and columns. <table> <tr> <td>column 1</td> <td>column 2</td> <td>column 3</td> </tr> <tr> <td> ...

issue with animation occurs when the value changes while the setTimeout timer is still running

function wallpaperMediaPropertiesListener(event) { // reset animation test.stop(true); test.css('margin-left', 0); // set song title. test.text(event.title); var testWidth = test.outerWidth(); // clone text ...

Creating a secure route with Vue and Firebase using Google Identity Platform

After successfully integrating Firebase (also known as Google Identity Platform) into my Vue project, I decided to secure specific routes. To achieve this, I made the following amendments: // router/index.js { path: '/profile', ...

Providing access to information even in the absence of JavaScript functionality

Is it possible to make the content of a webpage using jQuery/JavaScript visible even when JavaScript is disabled? Currently, I have a setup where clicking on an h2 header will display information from div tags using the jQuery function. I've made sur ...

Incorporating .json files into an HTML template with the help of an HTML form designed for selecting a particular

I am faced with a collection of various .json files that I wish to specify by name on an HTML page (local) form, enabling me to load this data onto a table. This is how my HTML form appears: <form> File: <input type="text" Id="file_name"&g ...

Display a progress bar in an application to visualize the loading of database records

Within my application, I am accepting a numerical input that is used to generate results on a separate page. The process involves running multiple sequential JDBC queries against Oracle database tables, resulting in a significant delay (1-2 minutes) for th ...

Unable to generate a vertical navigation bar

When attempting to create a vertical menu, the final result doesn't align as expected. https://i.stack.imgur.com/2ok47.jpg This is the current code being used: $("#example-one").append("<li id='magic-line'></li>") ...

Increasing the padding at the top of the logo when scrolling down the page

When scrolling down the page, there seems to be extra padding above the logo that is throwing off the alignment with the rest of the site. I've been trying different solutions to correct this issue: //$('.navbar-brand').css({ 'padding- ...

Encircle a circle within the Progress Tracker

Is there a way to create a ring around the circle in this progress tracker, similar to the image shown here? The progress tracker is based on You can view an example here. The CSS approach used was: .progress-step.is-active .progress-marker { backgrou ...