README / Hl2.html
hnynyosfe's picture
Upload Hl2.html
900b735 verified
Raw
History Blame Contribute Delete
3.8 kB
<!DOCTYPE html>
<html lang="ar" dir="rtl">
<head>
<meta charset="UTF-8">
<title>صفحة الويب</title>
<style>
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 100vh;
margin: 0;
background-color: #458299; /* لون الخلفية */
}
.cube-container {
width: 300px;
height: 300px;
perspective: 1000px;
transform-style: preserve-3d;
position: relative;
}
.cube {
width: 100%;
height: 100%;
position: relative;
transform-style: preserve-3d;
animation: rotate 8s linear infinite;
transition: opacity 0.5s ease; /* إضافة تأثير التلاشي */
}
@keyframes rotate {
from {
transform: rotateX(-45deg) rotateY(45deg) rotateZ(0deg);
}
to {
transform: rotateX(-45deg) rotateY(45deg) rotateZ(3600deg);
}
}
.face {
position: absolute;
width: 100px;
height: 100px;
opacity: 0.9;
display: flex;
align-items: center;
justify-content: center;
border: 2px solid #333;
box-sizing: border-box;
transition: transform 0.3s ease;
}
.face:hover {
transform: scale(1.1);
}
.front { background-color: #e0e0e0; transform: translateZ(50px); }
.back { background-color: #d0d0d0; transform: rotateY(180deg) translateZ(50px); }
.right { background-color: #c0c0c0; transform: rotateY(90deg) translateZ(50px); }
.left { background-color: #b0b0b0; transform: rotateY(-90deg) translateZ(50px); }
.top { background-color: #a0a0a0; transform: rotateX(90deg) translateZ(50px); }
.bottom { background-color: #909090; transform: rotateX(-90deg) translateZ(50px); }
.circle {
width: 60px;
height: 60px;
border-radius: 50%;
background-color: #007bff;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}
</style>
</head>
<body>
<div class="cube-container">
<div class="cube" id="myCube">
<div class="face front">
<div class="circle"></div>
</div>
<div class="face back">
<div class="circle"></div>
</div>
<div class="face right">
<div class="circle"></div>
</div>
<div class="face left">
<div class="circle"></div>
</div>
<div class="face top">
<div class="circle"></div>
</div>
<div class="face bottom">
<div class="circle"></div>
</div>
</div>
</div>
<script>
const cube = document.getElementById('myCube');
// طلب إذن الوصول إلى مستشعر الحركة
if (typeof DeviceMotionEvent.requestPermission === 'function') {
DeviceMotionEvent.requestPermission()
.then(permissionState => {
if (permissionState === 'granted') {
window.addEventListener('devicemotion', handleMotionEvent);
} else {
console.log('Permission to access device motion sensor was denied.');
}
})
.catch(console.error);
} else {
// مستشعر الحركة غير مدعوم
console.log('Device motion sensor is not supported on this device.');
}
function handleMotionEvent(event) {
const acceleration = event.accelerationIncludingGravity;
const cubeOpacity = 1 - Math.abs(acceleration.x / 10); // مثال: تلاشي المكعب عند إمالة الهاتف
cube.style.opacity = cubeOpacity;
}
</script>
</body>
</html>