<!DOCTYPE html>
|
<html lang="zh-CN">
|
<head>
|
<meta charset="UTF-8">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<title>横屏适配测试</title>
|
<style>
|
body {
|
margin: 0;
|
padding: 20px;
|
font-family: Arial, sans-serif;
|
background-color: #f0f0f0;
|
}
|
|
.test-container {
|
max-width: 1200px;
|
margin: 0 auto;
|
background: white;
|
border-radius: 10px;
|
padding: 20px;
|
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
}
|
|
.orientation-info {
|
background: #e8f4fd;
|
padding: 15px;
|
border-radius: 5px;
|
margin-bottom: 20px;
|
border-left: 4px solid #2196F3;
|
}
|
|
.canvas-simulation {
|
width: 300px;
|
height: 300px;
|
border: 3px solid #333;
|
border-radius: 50%;
|
margin: 20px auto;
|
position: relative;
|
background: #f9f9f9;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
}
|
|
.controls-simulation {
|
display: flex;
|
flex-wrap: wrap;
|
gap: 10px;
|
justify-content: center;
|
margin: 20px 0;
|
}
|
|
.button {
|
padding: 15px 25px;
|
background: #007bff;
|
color: white;
|
border: none;
|
border-radius: 5px;
|
cursor: pointer;
|
font-size: 16px;
|
min-width: 120px;
|
}
|
|
.button:hover {
|
background: #0056b3;
|
}
|
|
.landscape-layout {
|
display: flex;
|
align-items: flex-start;
|
gap: 40px;
|
}
|
|
.landscape-layout .canvas-simulation {
|
margin: 0;
|
flex-shrink: 0;
|
}
|
|
.landscape-layout .controls-simulation {
|
flex: 1;
|
flex-direction: column;
|
align-items: flex-start;
|
}
|
|
.test-buttons {
|
margin-top: 20px;
|
text-align: center;
|
}
|
|
.test-button {
|
margin: 5px;
|
padding: 10px 20px;
|
background: #28a745;
|
color: white;
|
border: none;
|
border-radius: 5px;
|
cursor: pointer;
|
}
|
|
.test-button:hover {
|
background: #218838;
|
}
|
|
.status {
|
margin-top: 20px;
|
padding: 10px;
|
background: #d4edda;
|
border-radius: 5px;
|
border-left: 4px solid #28a745;
|
}
|
|
@media (orientation: landscape) {
|
.test-container {
|
padding: 30px;
|
}
|
|
.canvas-simulation {
|
width: 400px;
|
height: 400px;
|
}
|
|
.button {
|
padding: 20px 30px;
|
font-size: 18px;
|
min-width: 150px;
|
}
|
}
|
|
@media (min-width: 1024px) {
|
.button {
|
padding: 25px 35px;
|
font-size: 20px;
|
min-width: 180px;
|
}
|
}
|
</style>
|
</head>
|
<body>
|
<div class="test-container">
|
<h1>横屏适配测试页面</h1>
|
|
<div class="orientation-info">
|
<h3>当前屏幕信息</h3>
|
<p><strong>屏幕尺寸:</strong> <span id="screenSize">检测中...</span></p>
|
<p><strong>方向:</strong> <span id="orientation">检测中...</span></p>
|
<p><strong>设备类型:</strong> <span id="deviceType">检测中...</span></p>
|
</div>
|
|
<div id="layoutContainer">
|
<!-- 画布模拟 -->
|
<div class="canvas-simulation">
|
<div style="text-align: center;">
|
<div style="width: 80px; height: 80px; background: #ddd; border-radius: 50%; margin: 0 auto 10px;"></div>
|
<div>车辆监控画布</div>
|
<div style="font-size: 12px; color: #666;">300x300px</div>
|
</div>
|
</div>
|
|
<!-- 控制按钮模拟 -->
|
<div class="controls-simulation">
|
<h3>控制区域</h3>
|
<div style="margin-bottom: 15px;">
|
<h4>红色层扇形控制</h4>
|
<div style="display: flex; gap: 5px; flex-wrap: wrap;">
|
<button class="button" style="background: #dc3545;">扇形1</button>
|
<button class="button" style="background: #dc3545;">扇形2</button>
|
<button class="button" style="background: #dc3545;">扇形3</button>
|
<button class="button" style="background: #dc3545;">扇形4</button>
|
</div>
|
</div>
|
|
<div style="margin-bottom: 15px;">
|
<h4>黄色层扇形控制</h4>
|
<div style="display: flex; gap: 5px; flex-wrap: wrap;">
|
<button class="button" style="background: #ffc107; color: #000;">扇形1</button>
|
<button class="button" style="background: #ffc107; color: #000;">扇形2</button>
|
<button class="button" style="background: #ffc107; color: #000;">扇形3</button>
|
<button class="button" style="background: #ffc107; color: #000;">扇形4</button>
|
</div>
|
</div>
|
|
<div style="margin-bottom: 15px;">
|
<h4>绿色层扇形控制</h4>
|
<div style="display: flex; gap: 5px; flex-wrap: wrap;">
|
<button class="button" style="background: #28a745;">扇形1</button>
|
<button class="button" style="background: #28a745;">扇形2</button>
|
<button class="button" style="background: #28a745;">扇形3</button>
|
<button class="button" style="background: #28a745;">扇形4</button>
|
</div>
|
</div>
|
|
<div style="margin-top: 20px;">
|
<button class="button" style="background: #6c757d;">还原</button>
|
<button class="button" style="background: #17a2b8;">开始</button>
|
<button class="button" style="background: #6f42c1;">设置</button>
|
</div>
|
</div>
|
</div>
|
|
<div class="test-buttons">
|
<button class="test-button" onclick="toggleLayout()">切换布局模式</button>
|
<button class="test-button" onclick="simulateOrientationChange()">模拟方向变化</button>
|
<button class="test-button" onclick="testResponsive()">测试响应式</button>
|
</div>
|
|
<div class="status" id="status">
|
状态: 正常
|
</div>
|
</div>
|
|
<script>
|
let isLandscape = false;
|
let isLayoutMode = false;
|
|
function updateScreenInfo() {
|
const width = window.innerWidth;
|
const height = window.innerHeight;
|
isLandscape = width > height;
|
|
document.getElementById('screenSize').textContent = `${width} x ${height}`;
|
document.getElementById('orientation').textContent = isLandscape ? '横屏' : '竖屏';
|
|
let deviceType = '手机';
|
if (width >= 1024 || height >= 1024) {
|
deviceType = '平板';
|
}
|
if (width >= 1366 || height >= 1366) {
|
deviceType = '大屏设备';
|
}
|
document.getElementById('deviceType').textContent = deviceType;
|
|
updateLayout();
|
}
|
|
function updateLayout() {
|
const container = document.getElementById('layoutContainer');
|
if (isLandscape || isLayoutMode) {
|
container.className = 'landscape-layout';
|
document.getElementById('status').textContent = '状态: 横屏布局模式';
|
} else {
|
container.className = '';
|
document.getElementById('status').textContent = '状态: 竖屏布局模式';
|
}
|
}
|
|
function toggleLayout() {
|
isLayoutMode = !isLayoutMode;
|
updateLayout();
|
}
|
|
function simulateOrientationChange() {
|
// 模拟方向变化
|
const container = document.querySelector('.test-container');
|
container.style.transform = 'rotate(90deg)';
|
setTimeout(() => {
|
container.style.transform = 'rotate(0deg)';
|
updateScreenInfo();
|
}, 1000);
|
}
|
|
function testResponsive() {
|
// 测试响应式
|
const buttons = document.querySelectorAll('.button');
|
buttons.forEach(button => {
|
button.style.animation = 'pulse 0.5s';
|
});
|
setTimeout(() => {
|
buttons.forEach(button => {
|
button.style.animation = '';
|
});
|
}, 500);
|
}
|
|
// 监听窗口大小变化
|
window.addEventListener('resize', updateScreenInfo);
|
|
// 监听方向变化
|
window.addEventListener('orientationchange', () => {
|
setTimeout(updateScreenInfo, 100);
|
});
|
|
// 初始化
|
updateScreenInfo();
|
|
// 添加CSS动画
|
const style = document.createElement('style');
|
style.textContent = `
|
@keyframes pulse {
|
0% { transform: scale(1); }
|
50% { transform: scale(1.05); }
|
100% { transform: scale(1); }
|
}
|
`;
|
document.head.appendChild(style);
|
</script>
|
</body>
|
</html>
|