bootstrap+svg实现图片过滤调节动画效果代码

代码语言:html

所属分类:其他

代码描述:bootstrap+svg实现图片过滤调节动画效果代码

代码标签: bootstrap svg 图片 过滤 调节 动画

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  
<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/bootstrap.5.3.0.css">
<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/bootstrap-icons.1.5.css">
  
<style>
body {
  padding: 0;
  margin: 0;
  background: #f5f5f5;
  font-family: "Plus Jakarta Sans", sans-serif;
}

h1,
h2,
h3,
h4,
h5 {
  font-weight: 700;
}

.container {
  display: flex;
  justify-content: center;
  gap: 20px;
}

input[type=range] {
  width:100%
}

.card {
  margin-top: 24px;
  margin-bottom: 24px;
  border-radius: 24px;
  padding: 24px;
  box-shadow: rgba(0, 0, 0, 0.1) 0px 10px 15px -3px,
    rgba(0, 0, 0, 0.05) 0px 4px 6px -2px;
  border: none;
}

.card h5 {
  margin-bottom: 24px;
}

.btn {
  border-radius: 24px;
  box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 3px 0px,
    rgba(0, 0, 0, 0.06) 0px 1px 2px 0px;
  margin: 4px;
  padding:8px 24px
}

.btn .bi {
  margin-right:6px
}


#toggleButtonShow {
  display:none
}

#container-row {
  background-color: #ddc;
  border: 50px solid #000;
  border-bottom-color: #333333;
  border-left-color: #252525;
  border-right-color: #252525;
  border-top-color: #000000;
  box-shadow: rgba(50, 50, 93, 0.25) 0px 13px 27px -5px,
    rgba(0, 0, 0, 0.3) 0px 8px 16px -8px;
  box-sizing: border-box;
  display: inline-block;
  margin-top: 24px;
  padding: 0;
  min-width: 1100px;
  transform: scale(0.8);
  transform-origin: top center;
}

.imgContainer {
  width: 500px;
  height: 500px;
  overflow: hidden;
  position: relative;
  float: left;
  transition: filter 0.5s ease;
}

.imgContainer:nth-child(2) {
  width: 500px;
  height: 500px;
  overflow: hidden;
  position: relative;
}

.image {
  width: 1920px;
  height: 2880px;
  object-fit: cover;
  object-position: top;
  margin-top: -290px;
  margin-left: -340px;
  filter: hue-rotate(0deg) contrast(160%) brightness(130%) sepia(30%);
}

.hair,
.mouth,
.eyelids,
.face {
  width: 1920px;
  height: 2880px;
  mix-blend-mode: color;
}

.bg {
  width: 1920px;
  height: 2880px;
  mix-blend-mode: normal;
}

.imgContainer:nth-child(1) .bg path {
  fill: #048ebc;
}

.imgContainer:nth-child(1) .hair path {
  fill: #eddd66;
}

.imgContainer:nth-child(1) .face path {
  fill: #754347;
}

.imgContainer:nth-child(1) .eyelids path {
  fill: #048ebc;
}
.imgContainer:nth-child(1) .mouth path {
  fill: #d22122;
}

.imgContainer:nth-child(2) .bg path {
  fill: #fc602f;
}

.imgContainer:nth-child(2) .hair path {
  fill: #fda660;
}

.imgContainer:nth-child(2) .face path {
  fill: #f9aecc;
}

.imgContainer:nth-child(2) .eyelids path {
  fill: #9274ba;
}
.imgContainer:nth-child(2) .mouth path {
  fill: #d22122;
}

.imgContainer:nth-child(3) .bg path {
  fill: #f83637;
}

.imgContainer:nth-child(3) .hair path {
  fill: #fad333;
}

.imgContainer:nth-child(3) .face path {
  fill: #ffffff;
}

.imgContainer:nth-child(3) .eyelids path {
  fill: #d22122;
}
.imgContainer:nth-child(3) .mouth path {
  fill: #d22122;
}

.imgContainer:nth-child(4) .bg path {
  fill: #00bc43;
}

.imgContainer:nth-child(4) .hair path {
  fill: #fd45e7;
}

.imgContainer:nth-child(4) .face path {
  fill: #d8b8fc;
}

.imgContainer:nth-child(4) .eyelids path {
  fill: #8aceac;
}
.imgContainer:nth-child(4) .mouth path {
  fill: #9d01fb;
}

.face {
  filter: hue-rotate(0deg);
}

.mouth {
  filter: hue-rotate(0deg);
}

.eyelids {
  filter: hue-rotate(0deg);
}

svg {
  position: absolute;
  top: 0;
  left: 0;
  margin-top: -290px;
  margin-left: -340px;
}

.hidden {
  display: none;
}

.credits {
  position:fixed;
  display:block;
  text-align:center;
  bottom: 0;
  max-width:100%;
  background: #f5f5f5;
  padding:16px;
  width:100%
}







@media only screen and (max-width: 600px) {
#container-row{
    transform:scale(0.3)
  };
  .card {
    margin-top:-700px
  }
}
@media only screen and (min-width: 600px) {
#container-row {
    transform:scale(0.5)
  };
  .card {
    margin-top:-500px
  }
}
@media only screen and (min-width: 768px) {
#container-row{
    transform:scale(0.6)
  };
  .card {
    margin-top:-400px
  }
}
@media only screen and (min-width: 992px) {
#container-row{
    transform:scale(0.6)
  };
  .card {
    margin-top:0px
  }
}
@media only screen and (min-width: 1200px) {
#container-row{
    transform:scale(0.8);
  .card {
    margin-top:0px
  }
  }
}
</style>

  
  
  
</head>

  <body>
  <header class="d-flex flex-wrap justify-content-center py-3 mb-4 border-bottom">
    <h1>Warholizer</h1>
  </header>

  <div class="container-sm">
    <div class="row">
      <div class="col-lg-3 order-lg-first order-last">
        <div class="card">
          <div class="card-body">
            <h5 class="card-title">Change the colors</h5>
            <div>
              <label for="range1">Image 1</label>
              <input type="range" id="range1" min="1" max="360" value="250">
            </div>
            <div>
              <label for="range2">Image 2</label>
              <input type="range" id="range2" min="1" max="360" value="50">
            </div>
            <div>
              <label for="range3">Image 3</label>
              <input type="range" id="range3" min="1" max="360" value="100">
            </div>
            <div>
              <label for="range4">Image 4</label>
              <input type="range" id="range4" min="1" max="360" value="30">
            </div>
            <div>
              <div class="d-grid gap-2">
                <button class="btn" id="play" data-toggle="tooltip" data-placement="top" title="Tooltip on top"><i class="bi bi-play-circle"></i>Play</button>
                <button class="btn" id="pause"><i class="bi bi-pause-circle"></i>Pause</button>
                <button class="btn" id="reset"><i class="bi bi-arrow-clockwise"></i>Reset</button>
                <button class="btn" id="toggleButtonShow"><i class="bi bi-eye-slash"></i>Hide Original</button>
                <button class="btn" id="toggleButtonHide"><i class="bi bi-eye"></i>Show Original</button>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="col-lg-9">
        <div class="row d-flex justify-content-center">
          <div id="container-row" class="row">
            <div class="imgContainer col-6" id="imgContainer">
              <img class="image" src="//repo.bfw.wiki/bfwrepo/image/66667b06908cf.png">
              <svg class="image">
                <filter id="posterize">
                  <feComponentTransfer>
                    <feFuncR type="discrete" tableValues="0 0.1 0.1" />
                  </feComponentTransfer>
                </filter>
                <image xlink:href="//repo.bfw.wiki/bfwrepo/image/66667b06908cf.png" width="100%" height="100%" x="0" y="0" filter="url(#posterize)"></image>
              </svg>
              <svg class="bg" width="1920" height="2880">
                <path d="M491.903,791.562L492.358,792.487L-0,792.487L-0,0L1920,0L1920,792.487L814.254,792.487C814.075,791.858 813.846,791.286 813.558,790.806C811.794,787.864 810.355,781.856 809.921,779.918C809.95,779.65 809.787,779.301 809.787,779.301C809.787,779.301 809.834,779.526 809.921,779.918C809.871,780.389 809.23,780.609 806.073,778.242C805.729,777.984 805.455,777.775 805.239,777.608C809.687,780.366 802.431,775.425 805.239,777.608C805.115,777.53 804.981,777.447 804.837,777.357C799.176,773.82 796.701,769.752 791.571,760.911C786.444,752.07 788.919,753.129 788.388,744.288C787.86,735.444 793.872,729.078 797.409,721.476C800.946,713.871 813.909,695.907 829.293,675.747C844.68,655.587 842.322,631.146 843.207,612.798C844.089,594.45 837.669,556.6.........完整代码请登录后点击上方下载按钮下载查看

网友评论0