The Vue Swiper does not support inline containers in my code

I am facing an issue with the layout of my simple swiper in my vue app. The containers are not inline as expected, causing the second one to appear under the first. Additionally, I am struggling with making the slider element visible only within the viewport of the swiper, indicated by a blue border.

My goal is to create a smooth and visually appealing slide show effect.

You can view my example here: https://jsfiddle.net/eywraw8t/547878/

Any suggestions on how I can resolve these issues?

<template>
    <div class="swiper">
        <transition-group
            tag="div"
            class="slides-group"
            :name="transitionName"
        >
            <div :key="currentIndex" class="slide">
                <slot v-bind:element="current" />
            </div>
        </transition-group>
        <div class="pagination">
            <button @click="next">next</button>
        </div>
    </div>
</template>
<script>
export default {
    props: {
        data: {
            type: Array,
            default: []
        }
    },
    data() {
        return {
            currentIndex: 0,
            transitionName: 'slide-next'
        }
    },
    computed: {
        current() {
            return this.data[this.currentIndex];
        }
    },
    methods: {
        next() {
            this.currentIndex++;
        }
    }
}
</script>
<style lang="scss" scoped>
.swiper {
    width: 100%;
    position: relative;
}
.slide-next-enter-active,
.slide-next-leave-active {
    transition: transform 0.5s ease-in-out;
}
.slide-next-enter {
    transform: translate(100%);
}
.slide-next-leave-to {
    transform: translate(-100%);
}
.slide-prev-enter-active,
.slide-prev-leave-active {
    transition: transform 0.5s ease-in-out;
}
.slide-prev-enter {
    transform: translate(-100%);
}
.slide-prev-leave-to {
    transform: translate(100%);
}
</style>

Answer №1

Here are some CSS adjustments you can try out: 1) For the .swiper class, include: overflow:hidden; 2) For the .slide class, include: display: inline-block;

After making these changes, customize your transition settings for a better appearance.

.swiper {
  margin-left: 100px;
  position: relative;
  border: 1px solid blue;
  overflow:hidden;
}

.slide {
  border: 1px solid red;
  width: 200px;
  height: 200px;
  display:inline-block;
}

Keep in mind that using an inline display may cause content to break into multiple lines if it exceeds the container's width. Consider setting absolute positions with fixed positioning and manipulating them to achieve your desired result.

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 error message "ERR_CONNECTION_TIMED_OUT when trying to access Google APIs fonts

Upon deploying my web project on the client server, I encountered an error and noticed slow page loading. GET https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic net::ERR_CONNECTION_TIMED_OUT The browser ...

Combining HTML/CSS to overlay text on an image - EMAIL

Why does Google keep stripping my <style> tag when I try to overlay text on an image? I want the image to be on the left with two text blocks positioned over it on the right (one higher and one lower). It looks fine visually, but when I send it to m ...

Issue with Bootstrap dropdown menu not showing up/functioning

I've spent the entire day trying to find a solution and experimenting with various methods, but I'm still unable to get it to work. The navbar-toggle (hamburger menu) shows up when the window is resized, but clicking on the button doesn't di ...

Ways to show dropdown menu link exclusively on mobile browsers and not on desktop browsers

<li class="megamenu-content"> <div class="megamenu-content-wrapper clearfix"> <ul class="col-lg-3 col-sm-3 col-md-3 "> <li class="cat-header">DISPLAY MEMBERS</li> ...

Implement a personalized Laravel Dusk selector with the attribute data-dusk

In the world of Laravel Dusk, the default selector hunts for the dusk="something" attribute in your HTML. If you want to dive deeper into this topic, check out this resource. However, when it comes to compatibility with Typescript for React/Vue, ...

Make the height of the CSS div fill the remaining space and allow scrolling once the maximum height of the screen is reached

I've scoured the internet high and low for a solution to my problem, but I just can't seem to find anything that fits my needs perfectly. The answers I have come across are either outdated or not quite what I'm looking for. I'm really h ...

How to retrieve values from Vue custom renderer's variable

I have been experimenting with implementing a custom renderer for the Vue Word Cloud component within Laravel. You can find the component here: https://github.com/SeregPie/VueWordCloud Initially, I prepare my word array using PHP (which is functioning co ...

Malfunctioning JavaScript timepiece

I am currently experimenting with using Raphael to create a unique clock feature on my website. My goal is to animate the seconds hand to mimic the movement of a traditional clock. Below is the code snippet I have implemented: window.onload = function( ...

Struggling to retrieve a JSON object from an Express and Node application, only receiving an empty result

Can anyone assist me? I'm having trouble with the res.json() function in my code. It seems to work after the first request, but not after the second. Right now, my application is quite simple - it scrapes user data from social media platforms like Twi ...

Having issues with the input event not triggering when the value is modified using jQuery's val() or JavaScript

When a value of an input field is changed programmatically, the expected input and change events do not trigger. Here's an example scenario: var $input = $('#myinput'); $input.on('input', function() { // Perform this action w ...

Ways to incorporate a dynamic HTML form that allows for input elements to be added both horizontally and vertically while maintaining connected lines

Looking to design a form that showcases HTML elements in both vertical and horizontal positions, with lines connecting them as seen in this example: https://i.sstatic.net/jB12f.png. Can anyone offer guidance on how to achieve this? Thanks! ...

Modifying the color of a non-active tab - Material UI Tabs

Is there a way to customize the color of inactive tabs in Material UI tabs? I have noticed that they currently appear black, as shown in the screenshot here: screenshot Thank you! ...

Exploring the world of flexbox and experimenting with implementing flex-wrap at a specific breakpoint

I am working on a layout that includes a module containing various content. My goal is to have the progress bar, along with the labels "parts" and "projects," positioned underneath an image and expand to the full width of the module when the window size go ...

Function that activates traffic lights

Currently, I'm encountering errors while working on this project in Notepad. Can you help me figure out what's wrong with my code? I'm attempting to create an onload traffic light using an object array. The requirement is to implement this f ...

I am looking to host two Nuxt.js (Vue.js) applications on a single server using PM2

To begin using Nuxt.js, follow these steps: vue init nuxt/express myapp1 vue init nuxt/express myapp2 The structure of my projects is as shown below. /workspace/myapp1 (Nuxt.js application) /workspace/myapp2 (Nuxt.js application) Within my workspace, ...

Tips for automatically displaying the scroll bar continuously on iOS 15 without requiring user interaction

We have a Web Application that displays a scroll bar for users to navigate through the content. The scroll bar functions correctly on desktop browsers and Android browsers, but not on Apple devices running iOS 15 (Safari Browser). Current Behavior : In ...

Creating a Vue application without the use of vue-cli and instead running it on an express

Vue has an interesting feature where vue-cli is not necessary for running it without a server. Initially, I thought otherwise. The Vue installation page at https://v2.vuejs.org/v2/guide/installation.html mentions using a script under CDN. <script src=&q ...

Exploring bidirectional component binding within Vue.js

As a newcomer to Vue.js, I was attempting to incorporate the currency filter example from the official guideline (example of currency filter). However, I encountered an issue when changing the property name of the component from 'value' to &apos ...

Foundation 4 Framework: Mastering the Art of Clearing CSS Floats

I'm currently in the process of developing a website, but I am facing difficulties with clearing the floats. My website is built using the foundation 4 framework. Whenever I apply the .columns class to an element, it causes the elements to float left. ...

Obtain the value of a two-handle slider using jQuery

Here is the HTML and JS setup I have for implementing a jQuery two-handle range slider: .html <p> <input class="amount" readonly style="border:0; color:black; background: transparent; text-align: center;" type="text"> </p> <div cla ...