js+css调用摄像头实现复古相机拍摄照片洗出排列效果代码
代码语言:html
所属分类:多媒体
代码描述:js+css调用摄像头实现复古相机拍摄照片洗出排列效果代码
代码标签: js css 调用 摄像头 复古 相机 拍摄 照片 洗出 排列
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
/>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/html2canvas.1.4.1.js"></script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Permanent+Marker&display=swap');
* {
box-sizing: border-box;
outline: none;
}
body {
margin: 0;
padding: 0;
background-color: #d4d4d4;
background-image: radial-gradient(#e0e0e0 15%, transparent 16%),
radial-gradient(#e0e0e0 15%, transparent 16%);
background-size: 20px 20px;
background-position: 0 0, 10px 10px;
height: 100vh;
width: 100vw;
font-family: sans-serif;
overflow: hidden;
display: flex;
flex-direction: row;
user-select: none;
touch-action: none;
}
.camera-zone {
flex: 0 0 50%;
max-width: 600px;
height: 100%;
display: flex;
flex-direction: column;
justify-content: flex-end;
align-items: center;
position: relative;
z-index: 20;
padding: 20px;
padding-bottom: 80px;
}
.camera-wrapper {
position: relative;
width: 100%;
max-width: 450px;
aspect-ratio: 1 / 1;
}
.camera-img {
width: 100%;
height: auto;
position: relative;
z-index: 20;
pointer-events: none;
filter: drop-shadow(0 20px 30px rgba(0, 0, 0, 0.4));
}
.lens-wrapper {
position: absolute;
bottom: 35%;
left: 62%;
transform: translateX(-50%);
width: 26%;
height: 26%;
border-radius: 50%;
overflow: hidden;
z-index: 25;
background: #000;
box-shadow: inset 0 0 15px #000;
}
video#cam-feed {
width: 100%;
height: 100%;
object-fit: cover;
transform: scaleX(-1);
opacity: 0.9;
}
.lens-shine {
position: absolute;
top: 15%;
left: 15%;
width: 30%;
height: 20%;
background: rgba(255, 255, 255, 0.3);
transform: rotate(-45deg);
filter: blur(3px);
z-index: 26;
pointer-events: none;
}
.shutter-btn {
position: absolute;
bottom: 42%;
left: 18%;
width: 11%;
height: 11%;
border-radius: 50%;
z-index: 30;
cursor: pointer;
-webkit-tap-highlight-color: transparent;
}
.ejection-slot {
position: absolute;
z-index: 15;
top: -40%;
left: 50%;
transform: translateX(-50%);
width: 35%;
height: 100%;
pointer-events: none;
display: flex;
align-items: flex-end;
justify-content: center;
padding-bottom: 20%;
}
.desk-zone {
flex: 1;
position: relative;
height: 100%;
}
/* --- Buttons --- */
.btn-container {
position: absolute;
top: 20px;
right: 20px;
z-index: 200;
display: flex;
gap: 10px;
}
.action-btn {
background: rgba(255, 255, 255, 0.9);
border: 2px solid #d93025;
color: #d93025;
padding: 8px 16px;
border-radius: 20px;
font-family: 'Permanent Marker', cursive;
font-size: 14px;
cursor: pointer;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
transition: all 0.2s;
}
.action-btn:hover {
background: #d93025;
color: white;
}
.action-btn:active {
transform: scale(0.95);
}
/* Specific style for download to look slightly different or same */
#download-btn {
border-color: #222;
color: #222;
}
#download-btn:hover {
background: #222;
color: white;
}
/* --- Polaroid Styling --- */
.polaroid {
width: 170px;
background: #fdfdfd;
padding: 10px 10px 55px 10px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
position: absolute;
cursor: grab;
pointer-events: auto;
transform-origin: center center;
touch-action: none;
transition: opacity 0.5s ease-out, transform 0.2s;
}
.polaroid:active {
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
z-index: 10000 !important;
}
.polaroid img {
width: 100%;
height: 170px;
object-fit: cover;
background: #222;
border: 1px solid #e0e0e0;
pointer-events: none;
display: block;
filter: blur(0) grayscale(0) brightness(1);
will-change: filter;
}
.polaroid.developing-start img {
filter: blur(15px) grayscale(0.5) brightness(0.9);
}
.polaroid.developing-slow img {
transition: filter 6s ease-in-out;
filter: blur(0) grayscale(0) brightness(1);
}
.polaroid.developing-fast img {
transition: filter 3s ease-out !important;
filter: blur(0) grayscale(0) brightness(1);
}
.polaroid .caption-main {
position: absolute;
bottom: 22px;
left: 10px;
width: 150px;
text-align: center;
color: #222;
opacity: 0.9;
cursor: text;
font-family: 'Permanent Marker', cursive;
font-size: 14px;
line-height: 1.1;
min-height: 18px;
}
.polaroid .caption-main:empty::before {
content: 'May I meet you';
opacity: 0.5;
}
.polaroid .caption-date {
position: absolute;
bottom: 8px;
left: 10px;
width: 150px;
text-align: center;
font-family: 'Permanent Marker', cursive;
font-size: 10px;
color: #555;
pointer-events: none;
user-select: none;
}
.polaroid.ejecting {
transform: translateY(100%);
animation: riseOut 2s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}
@keyframes riseOut {
0% {
transform: translateY(100%);
opacity: 1;
}
100% {
transform: translateY(-50px);
opacity: 1;
}
}
/* --- Share Button on Hover --- */
.polaroid-share-btn {
positi.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0