Vue application experiences issues with styles not displaying as expected

I've recently put together my very first Vue web application. As I was building it, I ran into an issue with my delete buttons not displaying correctly. No matter what styling adjustments I made, the problem persisted. Any suggestions on how to fix this?

Check out the Github Repo: https://github.com/Ocheezyy/VueTodo

View the live site here:

Here's a snippet of the Vue code in question:

<template>
    <div class="todo-item" v-bind:class="{'is-complete':todo.completed}">
        <input class="check" type="checkbox" v-on:change="markComplete">
        <p>{{todo.title}}</p>
        <button @click="$emit('del-todo', todo.id)" class="del">x</button>
    </div>
</template>

<script>
export default {
    name: "TodoItem",
    props: ["todo"],
    methods: {
        markComplete() {
            this.todo.completed = !this.todo.completed;
        }
    }
}
</script>

<style scoped>
    .todo-item {
        background: #f4f4f4;
        padding: 10px;
        border-bottom: 1px #ccc dotted;
        
    }

    .todo-item p{
        flex-grow:1;
    }

    .is-complete {
        text-decoration: line-through;
    }

    .del {
        background: #ff0000;
        color: #fff;
        border: none;
        padding: 5px 9px; 
        border-radius: 50%;
        cursor: pointer;
        float: right;
    }
</style>

Answer №1

Consider using flexBox instead of relying on floating elements.

Here is an example:

.todo-item {
    background: #f4f4f4;
    padding: 10px;
    border-bottom: 1px dotted #ccc;
    display: flex;
}

Remove the floats from both .check and .del.

Then include this CSS:

.todo-item p{
 flex-grow:1;
}

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

What are the steps to create fixed Angular Material Chips?

I'm currently attempting to achieve a similar look and functionality as demonstrated here: https://material.angularjs.org/1.1.9/demo/chips#static-chips where the chips are static and not selectable, clickable, or hoverable. However, I am utilizing Ang ...

Turn off HTML hyperlinks in Internet Explorer

I've been facing an issue in my application where I need to disable an HTML anchor using CSS. I found a solution on Stack Overflow that works perfectly in Chrome and Firefox. However, when I tried it in Internet Explorer, the link could not be disable ...

Ratios for Sizing Bootstrap Columns

The Bootstrap grid system consists of 12 columns in total. I am looking to utilize all 12 columns on the page. However, my goal is to have the first 6 columns on the left side be half the width (50%) of the columns on the right side. This means that the ...

Utilize the event bus by calling `this.$root.$emit` command

I recently implemented a basic Event bus in my application to dynamically change styles on a page, and it's functioning correctly. The event bus is triggered using the $emit and $on methods as shown below: EventBus.$on and EventBus.$emit('call ...

The vue template is indicating an error related to unused variables according to the eslint rule vue/no

Perhaps this information will come in handy for someone. I am working with a Vue template that contains HTML. <template slot="HEAD_Status" slot-scope="data"> <!-- some html without using of data --> </template> Eslint is showing [v ...

What is causing images to stretch unnecessarily in Flexbox on IE11?

I am encountering a problem with flexbox on IE11, and despite being aware of the numerous known issues, I am unable to find a solution... <div class="latest-posts"> <article class="post-grid"> <img src="http://lorempixel.com/ima ...

Chrome's CSS image transitions are causing interference with surrounding elements

I recently encountered an issue with my menu, where images used as backgrounds for buttons would animate on hover. Surprisingly, when I hovered over an image and it animated (by enlarging and rotating), other elements on the page would shift slightly witho ...

Chrome's behavior of reducing the width of inline elements when the content is dynamic

Upon opening the specified URL in Google Chrome, an issue can be observed where on the initial load everything appears fine. However, upon refreshing, the width of the three items at the top (Bedingungen, Preise, and So geht's) collapse. This seems to ...

Troubleshooting ng-bind-html issue with displaying images loaded using CSS within HTML content

I followed the instructions provided in a related post on the same topic. I used 'ngSanitize' and formatted the HTML content using 'sce.trustAsHtml()', and it rendered correctly when the HTML contained both text and images. However, I e ...

Having trouble with v-slide-group when there are only a few items present

I am encountering an issue with v-slide-group. Sometimes, I have only 2-3 items and other times, I have 10 items or more. However, when there are fewer items, the arrows do not show up and the slide-items are not centered. <div id="app"> ...

Convert a file to base64 using the v-file-input component in Vue.js with Vuetify

vue.js: <input type="file" @change="encodeFileToBase64" accept=".pdf, .docx"> </input> Is there a simple method to convert a file to base64 encoding in Vue.js? ...

Sending data from an HTML textarea to a PHP variable without user input

After spending more than two days searching for a solution to this problem, I am now reaching out directly with my question. Although there have been some hints and partial answers, nothing has definitively resolved the issue I am facing, prompting me to m ...

What is the best way to align my header buttons in the center and move items to the far right of my toolbar?

My header currently displays as follows: https://i.sstatic.net/h8zDQ.png I am aiming to center the [LEARN MORE, ABOUT, RESOURCES, CONTACT] buttons in the middle of the navbar and align the profile icon and switch button to the far right of the page! I en ...

Combine text in vue.js within a form

I'm looking to merge the texts I've created in vue into a single text Example: text field 1 = Code text field 2 = Area text field 3 = NumberCode Then I have one text field UniqueNumber, which is the value of this text field a combination of ...

Is there a way to pass locale data using props in VueJS Router?

To access hotel data, the URL path should be localhost:8080/hotel/:id (where id is equal to json.hoteID). For example, localhost:8080/hotel/101 This path should display the specific data for that hotel. In order to achieve this, we will utilize VueJS vu ...

Event listener is failing to execute the functions

Even though the inline onmouseover="verdadero()" function is properly set up Upon further inspection, it appears that while the event listener is added to the box element, the function is not being triggered when hovering over it, and console.lo ...

Is there a way to identify whether the image file is present in my specific situation?

I have a collection of images laid out as shown below image1.png image2.png image3.png image4.png … … image20.png secondImg1.png secondImg2.png secondImg3.png secondImg4.png secondImg5.png ……. …….. secondImg18.png My goal is to dynamically ...

Creating universal CSS for all platforms

Seeking assistance in making this Chrome CSS code compatible across different platforms. It currently does not function properly in Firefox and is completely non-functional in IE8. Your help is greatly appreciated, thank you for taking the time to read. . ...

Incorporate a Plugin within a Vue Custom Component

I recently learned about defining a custom element: const CustomElement = defineCustomElement(Panel); window.customElements.define('custom-commentpanel', CustomElement); Can anyone guide me on how to integrate a plugin like Vuex with this custom ...

Issue with redeployment on render.com, Nuxt Encountered Fatal Error

The recent update was successfully pushed to Github, but the redeploy on the hosting platform is encountering errors that I can't quite identify. I followed the suggestion in the error message and ran npm rebuild, but it didn't resolve the issue. ...