带有定制卡的Carousel carousel

发布于 2025-01-31 10:05:50 字数 2962 浏览 2 评论 0原文

试图将carousel用卡片使用而不是仅仅图像使用(例如图像在左侧,文本位于卡的右侧),锚标签“ < a class =“ carousel-item”> gt;“正在解决问题,我将其删除,我的卡状态正确,但无法移动卡,当我将其保留时,它将图像从卡片中取出并弄乱了。

/*materializecss*/
.carousel {
  overflow: hidden;
  position: relative;
  width: 100%;
  height: 400px;
  perspective: 500px;
  transform-style: preserve-3d;
  transform-origin: 0% 50%; }
  .carousel.carousel-slider {
    top: 0;
    left: 0; }
    .carousel.carousel-slider .carousel-fixed-item {
      position: absolute;
      left: 0;
      right: 0;
      bottom: 20px;
      z-index: 1; }
      .carousel.carousel-slider .carousel-fixed-item.with-indicators {
        bottom: 68px; }
    .carousel.carousel-slider .carousel-item {
      width: 100%;
      height: 100%;
      min-height: 400px;
      position: absolute;
      top: 0;
      left: 0; }
      .carousel.carousel-slider .carousel-item h2 {
        font-size: 24px;
        font-weight: 500;
        line-height: 32px; }
      .carousel.carousel-slider .carousel-item p {
        font-size: 15px; }
  .carousel .carousel-item {
    visibility: hidden;
    width: 200px;
    height: 200px;
    position: absolute;
    top: 0;
    left: 0; }
    .carousel .carousel-item > img {
      width: 100%; }
  .carousel .indicators {
    position: absolute;
    text-align: center;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0; }
    .carousel .indicators .indicator-item {
      display: inline-block;
      position: relative;
      cursor: pointer;
      height: 8px;
      width: 8px;
      margin: 24px 4px;
      background-color: rgba(255, 255, 255, 0.5);
      transition: background-color .3s;
      border-radius: 50%; }
      .carousel .indicators .indicator-item.active {
        background-color: #fff; }
  .carousel.scrolling .carousel-item .materialboxed,
  .carousel .carousel-item:not(.active) .materialboxed {
    pointer-events: none; }

/*custom css*/

.imp-card {
  width: 400px;
  height: 300px;
  display: flex;
  justify-content: center;
}

.image-section {
  width: 200px;
}

.pic-imp-layout {
  width: 100%;
  height: 100%;
}

.text-section {
  width: 200px;
  text-align: right;
  padding-right: 10px;
}
<div class="carousel">
  <a class="carousel-item">
    <div class="imp-card">
      <div class="image-section">
        <img class="pic-imp-layout" src="{% static 'images/img.jpg' %}">
      </div>
      <div class="text-section">
        <p class="score">Score</p>
        <p class="description"><a>&#x201C;</a> lorel ipsum<a>&#8221;</a></p>
        <p class="author">- John</p>
        <div class="like"></div>
        </div>
      </div>
    </div>
  </a>
</div>

trying to use materializecss carousel with cards instead of just images [such that image is to the left and texts are to the right side of the card], the anchor tag "<a class="carousel-item">" is making the problem, I remove it and my card is in proper shape but then not able to move the cards around, when I keep it in, it takes the images out of the cards and messes up.

/*materializecss*/
.carousel {
  overflow: hidden;
  position: relative;
  width: 100%;
  height: 400px;
  perspective: 500px;
  transform-style: preserve-3d;
  transform-origin: 0% 50%; }
  .carousel.carousel-slider {
    top: 0;
    left: 0; }
    .carousel.carousel-slider .carousel-fixed-item {
      position: absolute;
      left: 0;
      right: 0;
      bottom: 20px;
      z-index: 1; }
      .carousel.carousel-slider .carousel-fixed-item.with-indicators {
        bottom: 68px; }
    .carousel.carousel-slider .carousel-item {
      width: 100%;
      height: 100%;
      min-height: 400px;
      position: absolute;
      top: 0;
      left: 0; }
      .carousel.carousel-slider .carousel-item h2 {
        font-size: 24px;
        font-weight: 500;
        line-height: 32px; }
      .carousel.carousel-slider .carousel-item p {
        font-size: 15px; }
  .carousel .carousel-item {
    visibility: hidden;
    width: 200px;
    height: 200px;
    position: absolute;
    top: 0;
    left: 0; }
    .carousel .carousel-item > img {
      width: 100%; }
  .carousel .indicators {
    position: absolute;
    text-align: center;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0; }
    .carousel .indicators .indicator-item {
      display: inline-block;
      position: relative;
      cursor: pointer;
      height: 8px;
      width: 8px;
      margin: 24px 4px;
      background-color: rgba(255, 255, 255, 0.5);
      transition: background-color .3s;
      border-radius: 50%; }
      .carousel .indicators .indicator-item.active {
        background-color: #fff; }
  .carousel.scrolling .carousel-item .materialboxed,
  .carousel .carousel-item:not(.active) .materialboxed {
    pointer-events: none; }

/*custom css*/

.imp-card {
  width: 400px;
  height: 300px;
  display: flex;
  justify-content: center;
}

.image-section {
  width: 200px;
}

.pic-imp-layout {
  width: 100%;
  height: 100%;
}

.text-section {
  width: 200px;
  text-align: right;
  padding-right: 10px;
}
<div class="carousel">
  <a class="carousel-item">
    <div class="imp-card">
      <div class="image-section">
        <img class="pic-imp-layout" src="{% static 'images/img.jpg' %}">
      </div>
      <div class="text-section">
        <p class="score">Score</p>
        <p class="description"><a>“</a> lorel ipsum<a>”</a></p>
        <p class="author">- John</p>
        <div class="like"></div>
        </div>
      </div>
    </div>
  </a>
</div>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

幸福丶如此 2025-02-07 10:05:50

找到了解决问题的课程,poleterizecss类的预定高度和宽度会创建问题,父自定义卡,并且该类应该具有相同的分辨率,并且也不能在DIV的先前存在的锚定标签中使用锚定标签,一切正常。

.carousel .carousel-item {
    width: 200px;
    height: 200px;
}

found the class that was making the issue, the predetermined height and width of Materializecss class creates the issue, parent custom card and this class should have the same resolution and also can't use anchor tags inside the pre-existing anchor tag of the div, and everything is working normally.

.carousel .carousel-item {
    width: 200px;
    height: 200px;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文