Guide: Visual-First Web Cloning Recipe
Legal Notice: This skill is intended for cloning your own websites, building from design references you have rights to, or learning from public design patterns. Always ensure you have permission before reproducing third-party designs, assets, or branding. Respect copyright, trademarks, and terms of service.
When building a high-fidelity landing page clone, the biggest trap is relying purely on DOM trees and CSS dumps. Modern website builders (Framer, Webflow) generate deeply nested "div soup" and obfuscated CSS to create visual effects.
The Golden Rule: Trust your "eyes" (screenshots) first, but when an effect looks too complex to be pure CSS, use Deep DOM Interrogation to steal the exact asset.
The 80/20 Cloning Philosophy
To clone efficiently, you must divide your workflow into two distinct phases so you don't get bogged down pixel-pushing too early:
- 1. The 80% Sprint (Speed & Structure): Get the page laid out rapidly. Use Steps 0-2 to fetch the semantic HTML, scaffold the React component tree (
Navbar, Hero, Features), and apply basic Tailwind classes for layout (Flex/Grid) and spacing. Accept approximations here—use solid colors instead of complex gradients, standard CSS shadows, and static backgrounds. Move fast. - The 20% Polish (Pixel Perfection & Physics): Once the 80% structure is on screen, shift gears to meticulous engineering. Use Steps 3-5 to steal the exact math. This is where you use "Sniper CSS" to extract exact multi-stop gradients, rip WebGL canvas backgrounds to
.webm videos, map massive multi-layer box-shadows, and implement Framer Motion spring physics.
The 6-Step "Visual-First" Recipe
Step 0: Codebase Scaffolding Strategy
Before writing code, establish a scalable folder structure. Modern landing pages should be componentized.
- *
src/components/layout/: Navbar.tsx, Footer.tsx (Global elements) src/components/sections/: Hero.tsx, Features.tsx, Testimonials.tsx (Page blocks)src/components/ui/: Button.tsx, GlassCard.tsx (Reusable micro-components)src/assets/media/: Local storage for extracted videos, noise overlays, and icons.
Step 1: The "Eye Test" (Visual Grounding)
Before looking at a single line of code, visually ground yourself in the reference site.
- 1. Capture: Navigate to the target site and take a screenshot using an absolute path.
mcp_chrome-devtools_take_screenshot(filePath="/absolute/path/to/ref.png")
- 2. Analyze: Read the image (using your read image tool) and actively identify the Vibe:
-
Backgrounds: Is it flat? A subtle radial gradient? Are there sweeping SVG waves or floating blurred orbs?
-
Buttons: Are they flat? Glassmorphic (backdrop-blur)? Do they have glowing auras?
-
Typography: Which specific words are highlighted? Are there gradient text clips?
Step 2: Macro Structure Capture (Playwright/DOM Snapshot)
Best for: Getting the general layout semantic HTML structure (Nav, Hero, Bento Grid, Footer).
- - Take a DOM text snapshot using Chrome DevTools or Playwright to understand the section-by-section flow and extract the actual copy/text.
- Do not blindly copy the DOM. Distill the complicated nested builder divs into clean, semantic React (e.g.,
<section>, <nav>, <ul>).
Step 3: Micro Extraction (Sniper CSS)
Best for: Extracting exact pixel-perfect design tokens during the 20% Polish.
Tool to use: INLINECODE19
Do NOT query the full getComputedStyle object. It returns 500+ properties, overwhelms the context window, and creates hallucination/confusion. Instead, use targeted JS payloads to extract exactly what you need.
Script 1: Typography Tokens (Fonts, Spacing, Weights)
Why: To perfectly match headings. Used to discover that Calisto's H1 used -4.8px letter spacing and specific gray/blue hex colors.
CODEBLOCK0
Script 2: Bounding Box & Overflow (The Glow/Shadow Check)
Why: To find exact dimensions and see if glowing effects bleed outside the element. We used this to realize the Hero button was exactly 160x160px with overflow: visible, allowing inner conic gradients to blur outside the borders.
CODEBLOCK1
Script 3: Glassmorphism & Backgrounds
Why: To grab exact transparency, blur, and gradient values for navbars or cards.
CODEBLOCK2
Script 4: Typography & Forced Line-Breaks
Why: A clone looks instantly fake if text wraps differently than the original. Don't let the browser decide fluidly. Extract exact container widths to force identical line breaks.
CODEBLOCK3
Script 5: Abstract Glows & "Orbits" (The Glow Fallacy)
Why: A common trap is seeing a background aura and guessing it's a simple radial gradient with a massive blur(). High-end templates actually use hard shapes, multi-stop linear gradients, precise matrix transforms (rotations), and specific blend modes with a very tight blur. Eyeballing this turns a sharp "galaxy arm" into a muddy blob.
CODEBLOCK4
Step 4: Deep DOM Interrogation (The Secret Sauce)
Best for: Replicating complex glows, overlapping animations, and fluid backgrounds.
When an effect (like a smooth background or a swirling button) is too complex, do not guess the math. Framer and Webflow hide these in layered divs, pseudo-elements, or literal <video>/<canvas> tags.
Script 1: Render Engine Identification (Video vs Canvas vs CSS)
If the background is moving fluidly, you must determine what is rendering it before trying to clone it. Find the full-screen background node:
() => {
const backgrounds = [];
document.querySelectorAll('*').forEach(el => {
const style = window.getComputedStyle(el);
const rect = el.getBoundingClientRect();
// Look for large elements spanning >80% of screen in the background
if ((style.position === 'fixed' || style.position === 'absolute') &&
(parseInt(style.zIndex) <= 0 || style.zIndex === 'auto') &&
rect.width >= window.innerWidth * 0.8 &&
rect.height >= window.innerHeight * 0.5 &&
el.tagName !== 'BODY' && el.tagName !== 'HTML') {
backgrounds.push({ tag: el.tagName, html: el.outerHTML.substring(0, 300) });
}
});
return JSON.stringify(backgrounds, null, 2);
}
Lesson: The DOM never lies. You might discover the "complex animation" is actually:
- 1. A Video: A
<video src="...mp4"> tag (like in the Calisto template). Solution: Extract the URL and drop it in. - A WebGL Canvas: A
<canvas data-paper-shaders="true"> tag (like in the Portfolite template). Solution: Do not hack CSS. Scaffold React Three Fiber and write a GLSL shader. See Script 3. - A Noise Overlay: A repeating film-grain image (
background-image: url(...noise.png)) at 5-10% opacity layered over the effect to prevent color banding.
Script 2: Deep Extraction for UI Micro-Components (outerHTML)
To clone a complex modern button or pill badge, do not guess the CSS. Builders use massive multi-layered box-shadow strings (e.g., 6 layers of shadow) and precise rgba borders to create glowing depth. Extract its literal nested structure:
() => {
const btn = Array.from(document.querySelectorAll('a')).find(l => l.textContent.includes('Get Started'));
return btn ? btn.parentElement.outerHTML : 'Not found';
}
Lesson: This reveals the nested
conic-gradient divs,
blur() filters, and massive
box-shadow arrays. Map those literal strings directly into an arbitrary Tailwind class like
shadow-[0px_0.7px_..._rgba(...)].
Script 3: The API Interceptor (Shader Stealer)
If the target is using a WebGL <canvas>, the exact GLSL shader code is often minified in JS chunks. You can hijack the browser's WebGL API to intercept the raw shader math before it goes to the GPU.
Inject this script before the page loads (using initScript in mcp_chrome-devtools_navigate_page):
window.__interceptedShaders = [];
function hookContext(glPrototype) {
if (!glPrototype) return;
const originalShaderSource = glPrototype.shaderSource;
glPrototype.shaderSource = function(shader, source) {
window.__interceptedShaders.push(source);
originalShaderSource.call(this, shader, source);
};
}
hookContext(WebGLRenderingContext.prototype);
if (typeof WebGL2RenderingContext !== 'undefined') hookContext(WebGL2RenderingContext.prototype);
Then, evaluate
JSON.stringify(window.__interceptedShaders) to read the exact GLSL math!
Script 4: The "Last Resort" Canvas Recorder
When a WebGL Canvas shader is too heavily obfuscated to intercept (or relies on proprietary 3D math engines), do not try to guess the GLSL math. Instead, literally record the GPU output directly from the reference site and use it as a seamless background video.
CODEBLOCK8
Step 5: Synthesis & Rebuild (Tailwind + Framer Motion)
Best for: Translating visual effects into clean, modern tech stacks.
- 1. Build the Base (The 80%): Scaffold the structure using Step 2.
- Apply Tokens (The 20%): Plug in the exact colors, typography, and spacing from Step 3.
- Entrance Physics (The 20%): Use
framer-motion for buttery smooth spring entrances instead of standard CSS transitions. - Recreate the "Vibe":
-
Videos/Canvas: Drop the extracted
<video> tag directly into an absolute background container.
-
Framer Glows/Auras: Use layered absolute divs with exact gradient/blur tokens.
- 5. Verify (The Two-Tab & Stitch Workflow):
-
Two Tabs: Keep the reference site and your local clone open in separate MCP browser tabs.
-
CRITICAL - Explicit Page Selection: When juggling multiple tabs, taking a screenshot without focusing the tab will capture the wrong page or stale state. You MUST follow this exact sequence:
1.
mcp_chrome-devtools_list_pages to get the
pageId for both tabs.
2.
mcp_chrome-devtools_select_page(pageId=REF_ID) to explicitly focus the reference.
3. Take the reference screenshot with an absolute path (
ref_latest.png).
4.
mcp_chrome-devtools_select_page(pageId=LOCAL_ID) to explicitly focus your local clone.
5.
(Optional but recommended) Run
location.reload() via script if WebGL or HMR is stuck.
6. Take the local screenshot with an absolute path (
local_latest.png).
-
Side-by-Side Stitching: Use a quick Python script via your shell tool to stitch them together horizontally for a flawless 1:1 visual comparison:
python3 -c "
from PIL import Image
i1 = Image.open('/absolute/path/ref.png')
i2 = Image.open('/absolute/path/local.png')
h = min(i1.height, i2.height)
i1 = i1.resize((int(i1.width * h / i1.height), h))
i2 = i2.resize((int(i2.width * h / i2.height), h))
dst = Image.new('RGB', (i1.width + i2.width, h))
dst.paste(i1, (0, 0))
dst.paste(i2, (i1.width, 0))
dst.save('/absolute/path/combined.png')
"
-
Read: Use your read image tool on
combined.png to spot any remaining visual discrepancies side-by-side.
Troubleshooting & Best Practices
- - "The background animation is missing!" -> You assumed it was CSS. Run the Background Media script (Step 4) to find the hidden
<video> or <canvas> tag. - "The Button looks totally different!" -> Extract the
outerHTML of the button's parent. You likely missed overlapping blurred divs or 6-layer box shadows that create the glow effect. - "The Text Wraps Wrong!" -> You let the browser decide fluidly. Extract the exact bounding box width from the original and hardcode it (
max-w-[...]). - Save Paths: Always use Absolute Paths for saving screenshots to avoid losing them in the MCP server's hidden working directories.
- Zombie Browsers: If the DevTools server fails with a lock error, run
pkill -f "chrome-devtools-mcp" || true.
Ethical/Legal Note: When cloning websites, ensure you have the appropriate permissions. For learning purposes, focus on reverse-engineering the structural layout and design systems (spacing, colors, typography) rather than ripping proprietary copy, branding, or gated assets.
指南:视觉优先的网站克隆配方
法律声明: 本技能仅用于克隆您自己的网站、从您有权使用的设计参考中构建,或从公共设计模式中学习。在复制第三方设计、素材或品牌标识前,请务必确保您已获得许可。尊重版权、商标和服务条款。
在构建高保真落地页克隆时,最大的陷阱是纯粹依赖DOM树和CSS转储。现代网站构建器(Framer、Webflow)会生成深度嵌套的div汤和混淆的CSS来创建视觉效果。
黄金法则: 首先相信你的眼睛(截图),但当某个效果看起来过于复杂,不像是纯CSS能实现时,使用深度DOM探查来窃取确切的资源。
80/20克隆哲学
要高效克隆,你必须将工作流程分为两个不同的阶段,以免过早陷入像素级调整的泥潭:
- 1. 80%冲刺(速度与结构): 快速完成页面布局。使用步骤0-2获取语义化HTML,搭建React组件树(Navbar、Hero、Features),并应用基本的Tailwind类进行布局(Flex/Grid)和间距。这里接受近似值——使用纯色代替复杂渐变、标准CSS阴影和静态背景。快速推进。
- 20%精修(像素完美与物理效果): 一旦80%的结构呈现在屏幕上,切换到精细工程模式。使用步骤3-5窃取精确的数学参数。这是你使用狙击CSS提取精确的多段渐变、将WebGL画布背景转为.webm视频、映射多层大尺寸box-shadow以及实现Framer Motion弹簧物理效果的地方。
6步视觉优先配方
步骤0:代码库脚手架策略
在编写代码之前,建立可扩展的文件夹结构。现代落地页应该组件化。
- * src/components/layout/:Navbar.tsx、Footer.tsx(全局元素)
- src/components/sections/:Hero.tsx、Features.tsx、Testimonials.tsx(页面区块)
- src/components/ui/:Button.tsx、GlassCard.tsx(可复用的微组件)
- src/assets/media/:存储提取的视频、噪点叠加层和图标。
步骤1:视觉测试(视觉定位)
在查看一行代码之前,先在视觉上定位参考网站。
- 1. 捕获: 导航到目标网站并使用绝对路径截图。
mcp
chrome-devtoolstake_screenshot(filePath=/absolute/path/to/ref.png)
- 2. 分析: 读取图像(使用你的图像读取工具),并主动识别氛围:
-
背景: 是纯色?微妙的径向渐变?还是有流畅的SVG波浪或浮动模糊球体?
-
按钮: 是扁平?玻璃态(backdrop-blur)?有发光光晕?
-
排版: 哪些特定词语被突出显示?有渐变文字裁剪?
步骤2:宏观结构捕获(Playwright/DOM快照)
最佳用途:获取通用布局语义HTML结构(导航、英雄区、Bento网格、页脚)。
- - 使用Chrome DevTools或Playwright获取DOM文本快照,以理解逐区块的流程并提取实际的文案/文本。
- 不要盲目复制DOM。 将复杂的嵌套构建器div提炼为干净的语义化React(例如
步骤3:微观提取(狙击CSS)
最佳用途:在20%精修阶段提取精确的像素级完美设计令牌。
使用的工具: mcpchrome-devtoolsevaluate_script
不要查询完整的getComputedStyle对象。 它会返回500多个属性,压垮上下文窗口,并产生幻觉/混淆。相反,使用目标明确的JS负载来精确提取你需要的内容。
脚本1:排版令牌(字体、间距、字重)
原因:完美匹配标题。用于发现Calisto的H1使用了-4.8px字母间距和特定的灰/蓝十六进制颜色。
javascript
() => {
const el = document.querySelector(h1);
const s = window.getComputedStyle(el);
return JSON.stringify({
color: s.color,
fontSize: s.fontSize,
fontWeight: s.fontWeight,
letterSpacing: s.letterSpacing,
lineHeight: s.lineHeight
}, null, 2);
}
脚本2:边界框与溢出(发光/阴影检查)
原因:查找精确尺寸,并查看发光效果是否溢出元素边界。我们使用这个发现英雄按钮正好是160x160px,带有overflow: visible,允许内部锥形渐变模糊到边框之外。
javascript
() => {
const btn = Array.from(document.querySelectorAll(a)).find(l => l.textContent.includes(Get Started));
if (!btn) return Not found;
const rect = btn.getBoundingClientRect();
const s = window.getComputedStyle(btn);
return JSON.stringify({
width: rect.width,
height: rect.height,
display: s.display,
borderRadius: s.borderRadius,
overflow: s.overflow,
boxShadow: s.boxShadow
}, null, 2);
}
脚本3:玻璃态与背景
原因:获取导航栏或卡片的精确透明度、模糊和渐变值。
javascript
() => {
const el = document.querySelector(nav);
const s = window.getComputedStyle(el);
return JSON.stringify({
background: s.background,
backdropFilter: s.backdropFilter,
border: s.border
}, null, 2);
}
脚本4:排版与强制换行
原因:如果文本换行方式与原始不同,克隆会立即显得虚假。不要让浏览器自由决定。提取精确的容器宽度以强制相同的换行。
javascript
() => {
const el = document.querySelector(h1);
const r = el.getBoundingClientRect();
return JSON.stringify({
containerMaxWidth: r.width // 在Tailwind中使用(例如max-w-[900px])以强制精确换行!
}, null, 2);
}
脚本5:抽象发光与轨道(发光谬误)
原因:一个常见陷阱是看到背景光晕,猜测它是一个带有大blur()的简单径向渐变。高端模板实际上使用硬形状、多段线性渐变、精确矩阵变换(旋转)和特定的混合模式,配合非常紧凑的模糊。目测这个会把锐利的银河臂变成模糊的斑点。
javascript
() => {
const el = document.querySelector([data-framer-name=Big Circle]);
if (!el) return Not found;
const s = window.getComputedStyle(el);
return JSON.stringify({
background: s.background, // 捕获复杂的多段渐变
transform: s.transform, // 捕获关键的旋转角度
filter: s.filter, // 捕获精确的、通常小得惊人的模糊值
opacity: s.opacity
}, null, 2);
}
步骤4:深度DOM探查(秘密武器)
最佳用途:复制复杂的发光、重叠动画和流动背景。
当一个效果(如平滑背景或旋转按钮)过于复杂时,不要猜测数学参数。Framer和Webflow将这些隐藏在分层div、伪元素或字面意义上的
脚本1:渲染引擎识别(视频 vs 画布 vs CSS)
如果背景流畅移动,你必须在尝试克隆之前确定什么在渲染它。找到全屏背景节点:
javascript
() => {
const backgrounds = [];
document.querySelectorAll(*).forEach(el => {
const style = window.getComputedStyle(el);
const rect = el.getBoundingClientRect();
// 查找背景中占据屏幕>80%的大元素
if ((style.position === fixed || style.position === absolute) &&
(parseInt(style.zIndex) <= 0 || style.zIndex === auto) &&
rect.width >= window.innerWidth * 0.8 &&
rect.height >= window.innerHeight * 0.5 &&
el.tagName !== BODY && el.tagName !== HTML) {
backgrounds.push({ tag: el.tagName, html: el.outerHTML.substring(0, 300) });
}
});
return JSON.stringify(backgrounds, null, 2);
}
教训: DOM从不说谎。你可能会发现复杂动画实际上是:
- 1. 视频: 一个
- WebGL画布: 一个