List items and HTML buttons do not align correctly when placed side by side

As part of my efforts to deepen my understanding of Vuejs, I've taken on the task of building a traditional todo list app. While most of the functionality is working smoothly, I've encountered an issue with how the todo items are being displayed. The "delete" buttons for each item are overlapping into the row below, causing some visual clutter (refer to image).

What's puzzling is that the checkboxes are rendering correctly, but the buttons aren't. I attempted to adjust the CSS styling for the buttons to match that of the checkboxes, but it didn't resolve the problem.

TodoItem.vue

<template lang="html">
  <li class="todo-item" v-bind:class="{ 'is-complete': todo.completed }">
    <div class="checkbox-holder">
      <input type="checkbox" v-on:change="markComplete(todo.id)" />
    </div>
    <h2>{{ todo.title }}</h2>
    <button v-on:click="deleteTodo(todo.id)" class="del">x</button>
  </li>
</template>

App.scss

.todos {
  position: absolute;
  display: block;
  width: 656px;
  background-color: white;
  margin-left: 266px;
  border-right: $generic-border;
  min-height: calc(100vh);
  padding-left: 40px;
  padding-right: 40px;
  padding-top: 80px;
  padding-bottom: 80px;

  @include mq("900px") {
    margin-left: 0;
    width: auto;
  }
  h2 {
    font-size: 20px;
    font-weight: normal;
  }
  &__list li {
    line-height: 1.4;
    color: #333;
    font-size: 14px;
    list-style-type: none;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 20px;
    margin-top: 20px;
    padding: 20px;
    &.is-complete {
      text-decoration: line-through;
    }
    button {
      @include btn("30px");
      float: right;
      display: block;
    }
    .checkbox-holder {
      margin-right: 20px;
      margin-left: 20px;
      align-items: center;
      justify-content: center;
      line-height: 16px;
      float: left;
      .checkbox {
        cursor: pointer;
        border-color: gray;
        color: #343434;
        height: 16px;
        width: 16px;
        border: 1px solid gray;
        border-radius: 16px;
      }
    }
  }
}

The current layout of the buttons is shown here.

Answer №1

Check out the code snippet below.

li {
  display: flex;
  align-items: center;
}
<ul>
  <li class="todo-item">
    <div class="checkbox-holder">
      <input type="checkbox"/>
    </div>
    <h2>Hello world</h2>
    <button>x</button>
  </li>
</ul>

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 process of incorporating or expanding an object within a component

When using vue.js, you have the ability to iterate over an array of items in your template as shown below: <div id="app"> <div v-for="(item, i) in items">i: item</div> </div> <script> var example2 = new Vue({ el: &ap ...

Angular service unable to maintain data continuity across multiple controllers

I am facing an issue while attempting to set the title in controller1 using a service and then accessing the updated title in controller2. The function sharedProperties.setTitle(title) works perfectly fine in controller1, however, in controller2, I keep g ...

What is the best way to stop div animations when clicking with jQuery?

Upon loading the page, a div animates automatically. There is also a button present. When the button is clicked, I would like to create a new div and animate it the same way as the first one. However, when this happens, the position of the first div also ...

Preventing caching with HTML5 manifest

Hello, I have a question about disabling caching in my .NET web application. Currently, my XHTML web application is using the following meta tags: <meta http-equiv="Pragma" content="no-cache" /> <meta http-equiv="Expires" content="-1" /> <m ...

What is the best way to create a scrollable panel that spans the entire screen and stops just at the footer in a mobile interface using responsive design?

I am working on optimizing my result pages for mobile devices to ensure they are responsive across all screen sizes. However, I am struggling with making the scrollable panel fill the screen down to the footer consistently on all mobile devices. Setting a ...

Having trouble loading xml/xsl files on IE11? Consider enabling compatibility mode to ensure smooth rendering on your xml/xsl page

On my website, I have a page that displays XML from an XSL document. Strangely, it works perfectly on IE8 but not on IE11 - the page appears blank even though the XML is present when viewing the source. Interestingly, if I enable compatibility mode for the ...

Installing Vue JS through npm can be a time-consuming process

When running 'npm install' on a vue js project, it takes almost 2 minutes to download all dependencies listed. As a newcomer to both vue and npm, I'm curious if I can speed up this process by removing dependencies that aren't essential. ...

Removing the active class from a Bootstrap menu can be achieved by targeting the specific

I have successfully implemented a Bootstrap Menu by placing it in a separate header.html file and using the php include function to call that file on every page of my website. However, I am now trying to figure out how to dynamically change the active cl ...

Determining the visibility of an element on a webpage using JavaScript and Puppeteer

I've created a framework that scans websites hosted on our servers to ensure they comply with our policies. If any prohibited content is found, we capture a screenshot along with other relevant details. However, taking a screenshot may not be possibl ...

Have you utilized the `calc()` CSS property in a group while employing the margin shorthand?

Can we simplify the following code snippet by defining the value [6.25% - 5px] only once? margin-top:calc(6.25% - 5px);margin-bottom:calc(6.25% - 5px) Could it be optimized to something like this: margin:calc(6.25% 0 0 - 5px) However, the [0 0] part is ...

Challenges with border radius and table rendering in Internet Explorer 9

Apologies if the title is a bit off. The main issue I'm encountering pertains to border radius not functioning properly in IE9 on my website, while it works fine on other sites. Here's my CSS: border-radius: 6px; -webkit-border-radius: 6px; -mo ...

What's the Reason Behind My Array Populating on Rebuild but Not on Page Refresh?

I am currently utilizing a tech stack that includes Vue 3 with Composition API, a Pinia store, TypeScript, a SQL backend, and Fetch to retrieve data through my .NET 6 API. Within my codebase, I have a User.ts class: export default class User { userNam ...

Creating a Tree Checkbox using jQuery without relying on pre-made plugins

The data structure provided appears to be hierarchical, but I am unsure if it follows the Adjacency list or Nested List model. Regardless, it is relatively simple to gather this hierarchical data. For instance, to retrieve the entire tree, you can use: SE ...

Removing padding from the Bootstrap 5 navigation bar

One of my main concerns with the NavBar involves removing the padding and margin around the NavBar Item links. I have a left border and a background hover color that I want to expand the height of the NavBar, but so far, I haven't been successful in a ...

Troubles with Internet Explorer

I've been honing my skills in HTML & CSS and put together a page: Everything seems to be running smoothly except for one hiccup - the body text is not showing up in IE (specifically version 7). Take a look at the screenshot below for reference. If a ...

The CSS pointer cursor is not responding when applied to a div element

I'm having trouble changing the cursor type on a div. HTML: <div class='hover-effect'> <label for='file-input'> <img src='http://i.imgur.com/MIY6LmH.png' alt='Upload File' title='Up ...

Using TypeScript with React Bootstrap's <Col> component and setting the align attribute to 'center' can trigger a TS2322 warning

The React app I'm working on includes the code below. The Col component is imported from React-bootstrap <Col md={5} align="center"> This is a column </Col> When using Typescript, I received the following warning: ...

Unclear about how inheritance works with the general sibling combinator "~" (tilde)?

When attempting to color list items in an unordered list using the general sibling combinator, nothing seems to happen: http://jsfiddle.net/bkbehpv0/ p { color: blue } h1 ~ li { color: red; } <h1> Title of site </h1> <p> Text in t ...

Ways to eliminate extra spacing when search bar is expanded

My code is all contained within a header with the class 'example'. When the 'search' button is clicked, a div with the class 'search-bar' appears and its borders match those of the header. However, I want the search bar to ali ...

vue-router does not automatically navigate to a new route

Despite my numerous attempts to find the solution, I can't seem to figure out what is going wrong. I have been following this example. Here is how my VueRouter instance looks like. const router = new VueRouter({ mode: "history", routes: [ { ...