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.603 836.043,555.174C832.549,552.103 830.917,535.358 830.526,531.975C830.216,529.299 826.353,522.183 824.572,513.94C822.011,502.089 824.235,493.243 824.163,488.205C824.163,488.205 823.599,483.396 821.901,472.644C820.203,461.892 812.901,448.11 806.82,429.597C800.742,411.081 767.763,391.527 767.763,391.527C767.763,391.527 768.426,388.209 765.993,381.579C763.563,374.946 749.73,363.69 744.645,356.616C739.56,349.542 722.76,349.542 722.76,349.542C722.76,349.542 721.212,341.142 718.119,334.068C715.023,326.997 698.247,313.974 690.786,308.724C683.325,303.474 657.075,298.224 646.023,298.5C634.971,298.776 622.059,298.77 622.059,298.77C622.059,298.77 605.964,289.554 582.57,285.771C559.488,282.036 530.976,293.922 517.932,305.196C504.891,316.47 493.809,331.491 478.557,348.954C463.305,366.417 442.746,375.039 432.798,377.913C422.85,380.787 411.057,396.117 398.853,407.433C386.652,418.752 367.227,437.952 363.69,440.958C360.153,443.964 355.2,451.746 352.725,457.227C350.25,462.711 348.834,460.941 345.297,459.882C341.76,458.82 338.4,460.059 336.102,465.717C333.801,471.375 336.102,475.62 341.052,479.334C346.005,483.048 353.112,488.802 353.112,488.802C353.112,488.802 350.565,497.856 341.652,503.796C332.739,509.739 336.984,513.417 328.92,523.887C320.856,534.357 329.43,540.264 330.315,545.037C331.2,549.813 329.784,553.704 328.545,556.533C327.309,559.362 325.893,565.02 321.294,571.209C316.698,577.401 315.813,578.106 315.813,578.106C315.813,578.106 317.052,581.289 321.825,584.121C326.601,586.95 324.654,589.602 327.84,596.145C331.023,602.688 340.71,604.404 340.71,604.404C340.71,604.404 343.806,609.048 339.825,609.711C335.847,610.374 335.847,614.574 335.406,618.996C334.962,623.415 337.395,629.604 338.058,634.248C338.721,638.889 346.458,641.541 348.225,647.952C349.995,654.363 348.006,654.363 343.362,652.596C338.721,650.826 334.743,639.996 332.088,637.122C329.436,634.248 328.551,632.037 325.68,633.585C322.806,635.133 321.699,644.415 321.921,661.215C322.143,678.015 367.851,717.468 370.614,719.955C373.377,722.442 394.653,723.825 399.627,726.036C404.601,728.244 402.39,732.942 402.39,740.955C402.39,748.968 406.26,754.773 415.377,758.916C424.497,763.062 429.9,762.693 429.9,762.693L434.874,782.586L441.507,780.93C441.507,780.93 446.757,767.388 455.322,764.349C463.887,761.31 463.611,767.112 466.65,769.875C469.537,772.497 489.841,789.805 491.903,791.562ZM805.238,792.487L719.028,792.487L719.53,791.858C728.602,792.923 739.733,787.848 745.635,786.795C751.824,785.688 751.383,785.025 763.983,783.699C776.583,782.373 791.49,784.863 791.49,784.863C791.49,784.863 796.722,786.561 800.4,788.4C801.536,788.967 803.317,790.558 805.238,792.487Z" /> </svg> <svg class="face"> <path d="M809.921,779.918C809.834,779.527 809.787,779.302 809.787,779.302C809.787,779.302 809.949,779.65 809.921,779.918ZM491.192,786.487C491.706,789.419 492.072,791.706 492.072,791.706C492.072,791.706 469.691,772.639 466.651,769.876C463.611,767.113 463.888,761.31 455.322,764.35C446.757,767.389 441.507,780.93 441.507,780.93L434.875,782.587L429.901,762.693C429.901,762.693 424.497,763.061 415.377,758.917C406.26,754.772 402.39,748.969 402.39,740.956C402.39,732.943 404.601,728.245 399.627,726.035C394.653,723.825 373.377,722.443 370.614,719.956C367.851,717.469 322.143,678.016 321.921,661.216C321.699,644.416 322.806,635.133 325.679,633.584C328.552,632.037 329.436,634.248 332.088,637.122C334.742,639.996 338.721,650.827 343.362,652.596C348.005,654.364 349.994,654.363 348.226,647.953C346.457,641.542 338.721,638.89 338.058,634.248C337.395,629.605 334.963,623.416 335.405,618.996C335.848,614.574 335.847,610.374 339.826,609.711C343.806,609.048 340.71,604.405 340.71,604.405C340.71,604.405 331.023,602.688 327.84,596.145C324.655,589.602 326.6,586.951 321.826,584.121C317.051,581.291 315.813,578.107 315.813,578.107C315.813,578.107 316.697,577.4 321.294,571.209C325.892,565.02 327.308,559.362 328.546,556.533C329.783,553.703 331.199,549.813 330.315,545.037C329.43,540.264 320.857,534.357 328.921,523.887C336.985,513.418 332.739,509.738 341.653,503.796C350.565,497.855 353.112,488.802 353.112,488.802C353.112,488.802 346.005,483.048 341.053,479.333C336.101,475.62 333.802,471.376 336.102,465.717C338.401,460.059 341.76,458.821 345.297,459.882C348.834,460.942 350.249,462.71 352.725,457.227C355.2,451.746 360.153,443.965 363.69,440.958C367.227,437.952 386.651,418.751 398.853,407.434C411.056,396.116 422.85,380.786 432.799,377.913C442.746,375.039 463.305,366.418 478.557,348.954C493.809,331.491 504.891,316.469 517.933,305.196C530.975,293.921 559.487,282.037 582.569,285.771C605.964,.........完整代码请登录后点击上方下载按钮下载查看
网友评论0