如何在转盘中将SVG用作图像

时间:2018-10-24 11:55:15

标签: html5 css3

问候编码人员,请有人帮助我在Bootstrap 4 Caraousel中使用 SVG PATH D 。.Something Like This ...

我想将旋转木马做成这种形状(所有图像)。

https://exill.tn/demo/plex_html/template/triangle.html

https://exill.tn/demo/plex_html/template/img/home-area.jpg

->这是HTML

<div id="carouselIndicators" class="carousel slide" data-ride="carousel">
  <ol class="carousel-indicators">
    <li data-target="#carouselIndicators" data-slide-to="0" class="active"></li>
    <li data-target="#carouselIndicators" data-slide-to="1"></li>
    <li data-target="#carouselIndicators" data-slide-to="2"></li>
  </ol>
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img class="d-block w-100" src="img/slide-1.jpg" alt="First slide">
    </div>
    <div class="carousel-item">
      <img class="d-block w-100" src="img/slide-2.jpg" alt="Second slide">
    </div>
    <div class="carousel-item">
      <img class="d-block w-100" src="img/slide-3.jpg" alt="Third slide">
    </div>
  </div>
  <a class="carousel-control-prev" href="#carouselIndicators" role="button" data-slide="prev">
    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="carousel-control-next" href="#carouselIndicators" role="button" data-slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>
  <svg viewBox="0 0 1366 80" preserveAspectRatio="none">
    <path d="M0 0 683 75 1366 0 1366 -150 0 -150 0 0z"></path>
  </svg>
</div>

1 个答案:

答案 0 :(得分:1)

在正确的部分中将您的SVG代码添加为轮播项目

<div id="carouselIndicators" class="carousel slide" data-ride="carousel">
    <ol class="carousel-indicators">
        <li data-target="#carouselIndicators" data-slide-to="0" class="active"></li>
        <li data-target="#carouselIndicators" data-slide-to="1"></li>
        <li data-target="#carouselIndicators" data-slide-to="2"></li>
    </ol>
<div class="carousel-inner">
    <div class="carousel-item active">
        <img class="d-block w-100" src="img/slide-1.jpg" alt="First slide">
    </div>
    <div class="carousel-item">
        <img class="d-block w-100" src="img/slide-2.jpg" alt="Second slide">
    </div>
    <div class="carousel-item">
        <img class="d-block w-100" src="img/slide-3.jpg" alt="Third slide">
    </div>
    <!-- add svg in carousel -->
    <div class="carousel-item">
        <svg viewBox="0 0 1366 80" preserveAspectRatio="none">
             <path d="M0 0 683 75 1366 0 1366 -150 0 -150 0 0z"></path>
        </svg>
    </div>
</div>
<a class="carousel-control-prev" href="#carouselIndicators" role="button" data-slide="prev">
    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselIndicators" role="button" data- 
 slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
   <span class="sr-only">Next</span>
</a>