Bootstrap Vue Carousel height does not fit to full screen

折月煮酒 提交于 2019-12-11 15:19:23

问题


I am using Bootstrap Vue to create my carousel. The carousel contains 3 images that allow users to cycle through. I am able to display the images that fit the height and width of my laptop screen size. However, as I slowly reduce the screen size to mobile, the height does not feet the screen anymore. Below are my codes and screenshots

Update: I still cannot solve this issue, can anyone here me?

<template>
  <div>
    <b-carousel
      id="carousel-1"
      v-model="slide"
      :interval="4000"
      controls
      indicators
      background="#ababab"
      style="text-shadow: 1px 1px 2px #333;"
      @sliding-start="onSlideStart"
      @sliding-end="onSlideEnd"
    >
      <!-- Text slides with image -->
      <b-carousel-slide
        caption="First slide"
        text="Nulla vitae elit libero, a pharetra augue mollis interdum."
        img-src="https://source.unsplash.com/LAaSoL0LrYs/1920x1080"
      ></b-carousel-slide>

      <!-- Slides with custom text -->
      <b-carousel-slide img-src="https://source.unsplash.com/bF2vsubyHcQ/1920x1080">
        <h1>Hello world!</h1>
      </b-carousel-slide>

      <!-- Slides with image only -->
      <b-carousel-slide img-src="https://source.unsplash.com/szFUQoyvrxM/1920x1080"></b-carousel-slide>
    </b-carousel>

    <p class="mt-4">
      Slide #: {{ slide }}
      <br>
      Sliding: {{ sliding }}
    </p>
  </div>
</template>

<script>

export default {
  data() {
    return {
      slide: 0,
      sliding: null
    };
  },
  methods: {
    onSlideStart(slide) {
      this.sliding = true;
    },
    onSlideEnd(slide) {
      this.sliding = false;
    }
  }
};
</script>

Desktop screen:

Mobile screen:


回答1:


<b-carousel-slide v-for="(slide, index) in slides" :key="index">
   <template v-slot:img>
      <img
       class="d-block class-name"
       width="1024"
       :src="slide"
       alt="image slot">
    </template>
</b-carousel-slide>
<style>
.class-name{
height:100vh;
}
</style>


来源:https://stackoverflow.com/questions/55965592/bootstrap-vue-carousel-height-does-not-fit-to-full-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!