This skill converts UI screenshots or design images into production-ready HTML/CSS code that accurately replicates the visual appearance and layout of the original.
The user provides an image (screenshot, mockup, or design reference) showing a UI interface they want replicated.
Analysis Process
First, carefully analyze the image to understand:
- 1. Layout Structure
- Identify sections, containers, and nesting hierarchy
- Determine grid/flexbox patterns needed
- Note spacing relationships and alignment
- 2. Visual Elements
- Colors (hex/rgb values from the image)
- Typography (font families, sizes, weights)
- Icons and imagery
- Borders, shadows, gradients, effects
- 3. Component Types
- Headers, navigation, cards, buttons, inputs, tables, etc.
- Interactive elements and their states
- Data displays, labels, badges
- 4. Responsive Behavior
- How the layout might adapt to different screen sizes
- Mobile-first or desktop-first approach
Implementation Guidelines
HTML Structure:
- - Use semantic HTML5 elements (header, nav, main, section, article, footer)
- Create logical nesting that matches the visual hierarchy
- Use meaningful class names (BEM or similar convention)
CSS Styling:
- - Replicate colors exactly using values from the image
- Match typography (font family, size, weight, line-height, letter-spacing)
- Recreate spacing (margins, padding, gaps) accurately
- Implement visual effects (box-shadow, border-radius, gradients, backdrop-filter)
- Use CSS variables for theming when appropriate
Layout Techniques:
- - Flexbox for 1D layouts (rows or columns)
- CSS Grid for 2D layouts
- Position properties for overlays and absolute positioning
- Transform for rotations and scaling
Interactive Elements:
- - Add :hover, :focus states for buttons and links
- Include transitions for smooth state changes
- Consider adding basic JavaScript if the UI implies interactivity
Output Format
Provide a complete, self-contained HTML file with:
- - Proper DOCTYPE and HTML structure
- Embedded CSS in
<style> tags (or separate CSS file if complex) - All necessary meta tags for viewport/responsiveness
- Comments explaining major sections if helpful
If the design is complex, you may split into multiple files (HTML, CSS, JS).
Accuracy Priorities
- 1. Visual Fidelity: Match the original image as closely as possible
- Proportions: Maintain correct size ratios between elements
- Colors: Use exact or nearest-match color values
- Typography: Match font styles accurately
- Spacing: Replicate padding, margins, and gaps faithfully
Limitations to Communicate
- - Exact font matching may require web fonts (Google Fonts, etc.)
- Some effects may be approximated if the exact technique isn't visible
- Interactive behavior beyond hover states requires user specification
- Dynamic content should be represented with placeholder data
Multi-Image Handling
When the user provides multiple images at once, process each image individually and sequentially to ensure maximum quality:
Sequential Processing Workflow:
- 1. Process ONE image at a time through the complete conversion pipeline
- For each image:
- Analyze its unique layout, colors, typography, and components
- Create a dedicated HTML/CSS replica
- Verify visual fidelity before moving to the next
- 3. Maintain consistent naming conventions across all generated files
- After processing all images, provide a summary of all converted files
Output Organization:
- - Name files descriptively based on each image's content (e.g.,
login-page.html, dashboard.html) - If images represent different pages of the same site, maintain shared styles in a common CSS file when appropriate
- If images are unrelated, create self-contained HTML files for each
Quality Assurance:
- - Do NOT batch-process images together - each deserves full analysis attention
- If images are related (e.g., different screens of the same app), note shared components and reuse CSS where sensible
- Communicate progress to the user as you work through each image
Example Workflow
- 1. User provides UI screenshot(s)
- For each image:
- Analyze layout, colors, typography, components
- Create HTML structure matching the hierarchy
- Apply CSS to replicate visual appearance
- Add polish (hover states, transitions, responsive considerations)
- 3. Deliver complete HTML file(s) - one per input image (or split logically for multi-page designs)
Remember: The goal is a pixel-perfect replica that functions as a real web page, not just a close approximation. Pay attention to details like shadows, borders, gradients, and spacing - these make the difference between "close" and "indistinguishable."
技能名称: img2html
详细描述:
此技能可将UI截图或设计图片转换为可直接使用的HTML/CSS代码,精确还原原始图像的视觉外观与布局。
用户提供需要复制的UI界面图像(截图、设计稿或设计参考)。
分析流程
首先,仔细分析图像以理解以下内容:
- 1. 布局结构
- 识别区块、容器及嵌套层级
- 确定所需的网格/弹性盒模式
- 记录间距关系与对齐方式
- 2. 视觉元素
- 颜色(从图像中提取十六进制/RGB值)
- 排版(字体族、字号、字重)
- 图标与图像
- 边框、阴影、渐变、特效
- 3. 组件类型
- 页眉、导航、卡片、按钮、输入框、表格等
- 交互元素及其状态
- 数据展示、标签、徽章
- 4. 响应式行为
- 布局在不同屏幕尺寸下的适配方式
- 移动优先或桌面优先策略
实施指南
HTML结构:
- - 使用语义化HTML5元素(header、nav、main、section、article、footer)
- 创建与视觉层级匹配的逻辑嵌套
- 使用有意义的类名(BEM或类似命名规范)
CSS样式:
- - 使用图像中的颜色值精确还原色彩
- 匹配排版样式(字体族、字号、字重、行高、字间距)
- 精确还原间距(外边距、内边距、间隙)
- 实现视觉效果(盒阴影、圆角、渐变、背景模糊)
- 适当时使用CSS变量进行主题化
布局技术:
- - 一维布局使用弹性盒(行或列)
- 二维布局使用CSS网格
- 使用定位属性实现叠加和绝对定位
- 使用变换实现旋转和缩放
交互元素:
- - 为按钮和链接添加:hover、:focus状态
- 为平滑状态变化添加过渡效果
- 若UI暗示交互性,考虑添加基础JavaScript
输出格式
提供完整的独立HTML文件,包含: