Responsive Web 设
- 作者仓库星标 0
- 作者仓库 FarmFriend-Terminal-React
Responsive Web Design Skill Instructions
You are an expert responsive web designer who creates mobile-first, cross-device compatible interfaces. When this skill is triggered, apply modern responsive design patterns:
Mobile-First Philosophy
1. Progressive Enhancement
- Start with mobile design (320px+)
- Enhance for tablet (768px+)
- Optimize for desktop (1024px+)
- Add extras for wide screens (1280px+)
2. Breakpoint Strategy
/* Mobile-first breakpoints */
:root {
--break-mobile: 320px;
--break-tablet: 768px;
--break-desktop: 1024px;
--break-wide: 1280px;
}
/* Base styles (mobile) */
.container {
padding: var(--space-3);
max-width: 100%;
}
/* Tablet enhancements */
@media (min-width: 768px) {
.container {
padding: var(--space-4);
max-width: 720px;
margin: 0 auto;
}
}
/* Desktop enhancements */
@media (min-width: 1024px) {
.container {
padding: var(--space-6);
max-width: 960px;
}
}
/* Wide screen enhancements */
@media (min-width: 1280px) {
.container {
padding: var(--space-8);
max-width: 1200px;
}
}
Responsive Layout Systems
1. CSS Grid for Complex Layouts
/* Responsive grid system */
.responsive-grid {
display: grid;
gap: var(--space-4);
/* Mobile: 1 column */
grid-template-columns: 1fr;
}
@media (min-width: 768px) {
/* Tablet: 2 columns */
.responsive-grid {
grid-template-columns: repeat(2, 1fr);
}
}
@media (min-width: 1024px) {
/* Desktop: 3 columns */
.responsive-grid {
grid-template-columns: repeat(3, 1fr);
}
}
@media (min-width: 1280px) {
/* Wide: 4 columns */
.responsive-grid {
grid-template-columns: repeat(4, 1fr);
}
}
/* Auto-fit responsive grid */
.auto-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: var(--space-4);
}
/* Auto-fill with minimum size */
.feature-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
gap: var(--space-4);
}
2. Flexbox for Component Layouts
/* Responsive flexbox layout */
.flex-container {
display: flex;
flex-direction: column;
gap: var(--space-3);
}
@media (min-width: 768px) {
.flex-container {
flex-direction: row;
flex-wrap: wrap;
}
}
/* Responsive flexbox cards */
.flex-cards {
display: flex;
flex-direction: column;
gap: var(--space-4);
}
.flex-card {
flex: 1;
}
@media (min-width: 768px) {
.flex-cards {
flex-direction: row;
}
.flex-card {
flex: 1 1 45%;
}
}
@media (min-width: 1024px) {
.flex-card {
flex: 1 1 30%;
}
}
3. Container Queries (Modern)
/* Component-level responsiveness */
.component-container {
container-type: inline-size;
}
/* Card adapts to available space */
.adaptive-card {
padding: var(--space-3);
}
@container (min-width: 400px) {
.adaptive-card {
padding: var(--space-4);
display: grid;
grid-template-columns: 1fr 2fr;
gap: var(--space-3);
}
}
@container (min-width: 600px) {
.adaptive-card {
padding: var(--space-6);
grid-template-columns: 1fr 3fr 1fr;
}
}
Responsive Typography
1. Fluid Typography Scale
/* Fluid typography using clamp() */
:root {
--font-fluid-sm: clamp(0.875rem, 0.875rem + 0.25vw, 1rem);
--font-fluid-base: clamp(1rem, 1rem + 0.25vw, 1.125rem);
--font-fluid-lg: clamp(1.125rem, 1.125rem + 0.5vw, 1.5rem);
--font-fluid-xl: clamp(1.5rem, 1.5rem + 1vw, 2.25rem);
--font-fluid-2xl: clamp(2.25rem, 2.25rem + 1.5vw, 3rem);
--font-fluid-3xl: clamp(3rem, 3rem + 2vw, 4rem);
}
h1 { font-size: var(--font-fluid-3xl); line-height: 1.2; }
h2 { font-size: var(--font-fluid-2xl); line-height: 1.3; }
h3 { font-size: var(--font-fluid-xl); line-height: 1.4; }
h4 { font-size: var(--font-fluid-lg); line-height: 1.5; }
p { font-size: var(--font-fluid-base); line-height: 1.6; }
small { font-size: var(--font-fluid-sm); line-height: 1.6; }
2. Responsive Spacing
/* Responsive spacing using custom properties */
.responsive-section {
padding: var(--space-4);
margin-bottom: var(--space-6);
}
@media (min-width: 768px) {
.responsive-section {
padding: var(--space-6);
margin-bottom: var(--space-8);
}
}
@media (min-width: 1024px) {
.responsive-section {
padding: var(--space-8);
margin-bottom: var(--space-12);
}
}
/* Container padding for breakpoints */
.responsive-container {
padding: var(--space-3);
}
@media (min-width: 768px) {
.responsive-container {
padding: var(--space-4) var(--space-6);
}
}
@media (min-width: 1024px) {
.responsive-container {
padding: var(--space-6) var(--space-8);
}
}
Touch and Mobile Optimization
1. Touch-Friendly Targets
/* Minimum touch target 44px */
.touch-target {
min-height: 44px;
min-width: 44px;
padding: var(--space-2) var(--space-3);
}
/* Large tap areas for mobile */
.mobile-button {
padding: var(--space-3) var(--space-4);
font-size: var(--font-lg);
min-height: 48px;
}
/* Spacing for touch accuracy */
.mobile-link {
display: block;
padding: var(--space-3);
margin: var(--space-2) 0;
}
/* Touch-optimized form inputs */
.mobile-input {
font-size: 16px; /* Prevents zoom on iOS */
padding: var(--space-3);
min-height: 48px;
border-radius: var(--space-2);
}
2. Mobile Navigation Patterns
/* Hamburger menu for mobile */
.mobile-nav {
display: block;
}
.desktop-nav {
display: none;
}
@media (min-width: 768px) {
.mobile-nav { display: none; }
.desktop-nav { display: flex; }
}
/* Mobile navigation drawer */
.nav-drawer {
position: fixed;
top: 0;
left: -100%;
width: 280px;
height: 100vh;
background: white;
z-index: 1000;
transition: left 0.3s ease;
}
.nav-drawer.open {
left: 0;
}
.nav-drawer-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 999;
opacity: 0;
visibility: hidden;
transition: opacity 0.3s ease, visibility 0.3s ease;
}
.nav-drawer-overlay.open {
opacity: 1;
visibility: visible;
}
3. Mobile-Specific Optimizations
/* Viewport meta for mobile */
<meta name="viewport" content="width=device-width, initial-scale=1.0">
/* Prevent horizontal scrolling on mobile */
body {
overflow-x: hidden;
-webkit-text-size-adjust: 100%;
}
/* Mobile-first image sizing */
.responsive-image {
max-width: 100%;
height: auto;
}
/* Mobile table patterns */
.mobile-table {
display: block;
width: 100%;
overflow-x: auto;
}
@media (min-width: 768px) {
.mobile-table {
display: table;
}
}
Performance and Optimization
1. Responsive Images
<!-- Art direction for responsive images -->
<picture>
<source media="(min-width: 1024px)" srcset="hero-large.webp">
<source media="(min-width: 768px)" srcset="hero-medium.webp">
<img src="hero-small.webp" alt="Hero image" loading="lazy">
</picture>
<!-- Density switching for high-DPI displays -->
<img src="image-1x.webp"
srcset="image-1x.webp 1x, image-2x.webp 2x"
alt="Responsive image" loading="lazy">
<!-- Responsive embedded images -->
<style>
.hero-image {
background-image: url('hero-small.webp');
}
@media (min-width: 768px) {
.hero-image {
background-image: url('hero-medium.webp');
}
}
@media (min-width: 1024px) {
.hero-image {
background-image: url('hero-large.webp');
}
}
</style>
2. CSS Optimization for Responsive Design
/* Efficient media queries */
@media (min-width: 768px) and (max-width: 1023px) {
/* Tablet-specific styles */
}
/* Container queries for component adaptation */
@container (min-width: 300px) and (max-width: 600px) {
/* Component-specific responsive styles */
}
/* Reduce motion on mobile */
@media (prefers-reduced-motion: reduce), (max-width: 768px) {
.animated {
animation: none;
transition: none;
}
}
/* Dark mode support */
@media (prefers-color-scheme: dark) {
.responsive-component {
background: var(--color-neutral-dark);
color: var(--color-text-dark);
}
}
Responsive Component Patterns
1. Responsive Card Grid
<div class="responsive-cards">
<article class="card">
<img src="image.jpg" alt="Card image" loading="lazy">
<h3>Card Title</h3>
<p>Card content...</p>
</article>
<!-- More cards -->
</div>
<style>
.responsive-cards {
display: grid;
gap: var(--space-4);
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.card {
background: white;
border-radius: var(--space-2);
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
overflow: hidden;
transition: transform 0.2s ease;
}
.card:hover {
transform: translateY(-4px);
box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}
.card img {
width: 100%;
height: 200px;
object-fit: cover;
}
.card h3 {
padding: var(--space-3);
margin: 0;
font-size: var(--font-lg);
}
.card p {
padding: 0 var(--space-3) var(--space-3);
margin: 0;
color: var(--color-secondary);
}
</style>
2. Responsive Sidebar Layout
<div class="responsive-layout">
<aside class="sidebar">
<nav class="sidebar-nav">
<!-- Navigation items -->
</nav>
</aside>
<main class="main-content">
<!-- Main content -->
</main>
</div>
<style>
.responsive-layout {
display: flex;
flex-direction: column;
min-height: 100vh;
}
.sidebar {
order: 2;
width: 100%;
background: var(--color-neutral);
padding: var(--space-4);
}
.main-content {
order: 1;
flex: 1;
padding: var(--space-4);
}
@media (min-width: 768px) {
.responsive-layout {
flex-direction: row;
}
.sidebar {
order: 1;
width: 250px;
min-height: 100vh;
}
.main-content {
order: 2;
}
}
@media (min-width: 1024px) {
.sidebar {
width: 300px;
}
}
</style>
3. Responsive Header
<header class="responsive-header">
<div class="header-brand">
<img src="logo.svg" alt="Logo" class="logo">
<span class="brand-name">Brand</span>
</div>
<button class="mobile-menu-toggle" aria-label="Toggle menu">
<span></span>
<span></span>
<span></span>
</button>
<nav class="header-nav" aria-label="Main navigation">
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#services">Services</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
</header>
<style>
.responsive-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: var(--space-3);
background: white;
border-bottom: 1px solid var(--color-border);
}
.header-brand {
display: flex;
align-items: center;
gap: var(--space-2);
}
.logo {
width: 32px;
height: 32px;
}
.brand-name {
font-size: var(--font-lg);
font-weight: 700;
color: var(--color-primary);
}
.mobile-menu-toggle {
display: flex;
flex-direction: column;
justify-content: space-around;
width: 32px;
height: 32px;
background: transparent;
border: none;
cursor: pointer;
}
.mobile-menu-toggle span {
width: 24px;
height: 2px;
background: var(--color-primary);
transition: all 0.3s ease;
}
.header-nav {
display: none;
}
@media (min-width: 768px) {
.mobile-menu-toggle { display: none; }
.header-nav {
display: flex;
align-items: center;
}
.header-nav ul {
display: flex;
list-style: none;
margin: 0;
padding: 0;
gap: var(--space-4);
}
.header-nav a {
padding: var(--space-2) var(--space-3);
color: var(--color-primary);
text-decoration: none;
border-radius: var(--space-1);
transition: background 0.2s ease;
}
.header-nav a:hover {
background: var(--color-primary);
color: white;
}
}
</style>
Testing and Debugging
1. Responsive Testing Approach
// Add viewport indicator for development
function addViewportIndicator() {
if (window.location.hostname === 'localhost') {
const indicator = document.createElement('div');
indicator.style.cssText = `
position: fixed;
top: 10px;
right: 10px;
background: rgba(0,0,0,0.8);
color: white;
padding: 8px 12px;
border-radius: 4px;
font-size: 12px;
z-index: 9999;
font-family: monospace;
`;
const updateIndicator = () => {
indicator.textContent = `${window.innerWidth}x${window.innerHeight}`;
};
updateIndicator();
window.addEventListener('resize', updateIndicator);
document.body.appendChild(indicator);
}
}
// Detect device type
function getDeviceType() {
const width = window.innerWidth;
if (width < 768) return 'mobile';
if (width < 1024) return 'tablet';
return 'desktop';
}
2. Common Responsive Issues and Solutions
/* Prevent horizontal scrolling */
.responsive-container {
max-width: 100%;
overflow-x: hidden;
box-sizing: border-box;
}
/* Fix iOS viewport bug */
.ios-fix {
padding-bottom: env(safe-area-inset-bottom);
padding-left: env(safe-area-inset-left);
padding-right: env(safe-area-inset-right);
}
/* Handle cut off text */
.text-truncate {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
/* Responsive text wrapping */
.text-responsive {
word-wrap: break-word;
overflow-wrap: break-word;
hyphens: auto;
}
Implementation Strategy
When creating responsive designs:
- Mobile-First: Start with mobile design and progressively enhance
- Touch-Optimized: Ensure minimum 44px touch targets
- Performance: Optimize images and CSS for each breakpoint
- Accessibility: Maintain accessibility across all device sizes
- Testing: Test on actual devices, not just browser resizing
- Progressive Enhancement: Core functionality works everywhere
- Flexible Units: Use rem, em, %, vw, vh for scalability
- Modern CSS: Leverage Grid, Flexbox, and Container Queries
Create responsive interfaces that provide optimal user experience across all devices and screen sizes.
- 流狐分类
- 设计与多媒体
- 作者声明 Agent
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 92 / 100 · 启发式扫描,不代表运行安全
- 作者 / 版本 / 许可
- @0-CYBERDYNE-SYSTEMS-0 · v1.0 · 未声明 license
- 流狐 Token 估算
- 中等消耗
- 流狐接入估算
- 需简单配置
- 是否需要外部 API Key
- 未发现要求
- 检测到的系统要求
- 未声明
- 底层运行要求
- 未声明
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- 检测到的网络行为
- 仅限本地
- 安装命令数
- 无(仅作为资料)
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
作者没有在当前 SKILL.md 中定义固定输出样例。 Mobile-First Philosophy
Mobile-First Philosophy
1. Progressive Enhancement
Start with mobile design (320px+) Enhance for tablet (768px+) Optimize for desktop (1024px+)
2. Breakpoint Strategy
2. Breakpoint Strategy
Responsive Layout Systems
Responsive Layout Systems
1. CSS Grid for Complex Layouts
1. CSS Grid for Complex Layouts
2. Flexbox for Component Layouts
2. Flexbox for Component Layouts
# Responsive Web Design Skill Instructions
You are an expert responsive web designer who creates mobile-first, cross-device compatible interfaces. When this skill is triggered, apply modern responsive design patterns:
## Mobile-First Philosophy
### 1. Progressive Enhancement
- Start with mobile design (320px+)
- Enhance for tablet (768px+)
- Optimize for desktop (1024px+)
- Add extras for wide screens (1280px+)
### 2. Breakpoint Strategy
```css
/* Mobile-first breakpoints */
:root {
--break-mobile: 320px;
--break-tablet: 768px;
--break-desktop: 1024px;
--break-wide: 1280px;
}
/* Base styles (mobile) */
.container {
padding: var(--space-3);
max-width: 100%;
}
/* Tablet enhancements */
@media (min-width: 768px) {
.container {
padding: var(--space-4);
max-width: 720px;
margin: 0 auto;
}
}
/* Desktop enhancements */
@media (min-width: 1024px) {
.container {
padding: var(--space-6);
max-width: 960px;
}
}
/* Wide screen enhancements */
@media (min-width: 1280px) {
.container {
padding: var(--space-8);
max-width: 1200px;
}
}
```
## Responsive Layout Systems
### 1. CSS Grid for Complex Layouts
```css
/* Responsive grid system */
.responsive-grid {
display: grid;
gap: var(--space-4);
/* Mobile: 1 column */
grid-template-columns: 1fr;
}
@media (min-width: 768px) {
/* Tablet: 2 columns */
.responsive-grid {
grid-template-columns: repeat(2, 1fr);
}
}
@media (min-width: 1024px) {
/* Desktop: 3 columns */
.responsive-grid {
grid-template-columns: repeat(3, 1fr);
}
}
@media (min-width: 1280px) {
/* Wide: 4 columns */
.responsive-grid {
grid-template-columns: repeat(4, 1fr);
}
}
… 证据边界与执行链路
作者原文负责流程事实;流狐只索引当前章节、要点、文件与命令。
章节 -> Mobile-First Philosophy → 1. Progressive Enhancement → 2. Breakpoint Strategy → Responsive Layout Systems → 1. CSS Grid for Complex Layouts → 2. Flexbox for Component Layouts
要点 -> Mobile-First · Touch-Optimized · Performance · Accessibility · Testing · Progressive Enhancement · Flexible Units · Modern CSS
文件/命令 -> ${window.innerWidth}x${window.innerHeight}
内容 SHA-256 -> 418fddd1f689
方法与流程
适用与边界
原文中的明确线索
${window.innerWidth}x${window.innerHeight}