path
Jin's Lab
코드로 실험하고 기록하는 개발 일지 · J.Lab

Jin's Lab

코드로 실험하고 기록하는 개발 일지. 커리어와 삶의 방향을 탐색하며 기록하는 공간입니다

css-axis-rotation

flex-direction align-items 버그로 모바일 화면이 한쪽으로 쏠렸던 이유

J.Lab ·
목차

    최근 운영 중인 네 개의 블로그인 이슈로그, KidStory, Jin's Lab, 링크허브를 모니터링하던 중 예상치 못한 화면 깨짐 현상을 발견했다. 개발자도구의 모바일 프리뷰 기능을 켜고 뷰포트를 768px 부근으로 줄여보니, 본문 콘텐츠가 중앙에 예쁘게 정렬되지 않고 왼쪽으로 보기 싫게 쏠려 있는 것이었다. 데스크톱 화면에서는 아무런 문제가 없었기에 모바일 환경에 대응하는 과정에서 무언가 꼬였다는 직감이 들었다. 원인을 정확히 파악하기 위해 즉시 디버깅에 착수했다.

    원격 브라우저의 한계를 iframe으로 우회하여 디버깅하기

    문제는 내가 사용하던 일부 테스트 도구가 실제 뷰포트 리사이즈를 완벽하게 지원하지 않는 원격 브라우저였다는 점이다. 실시간으로 요소를 검사하며 수치를 보고 싶었지만 도구의 한계로 인해 768px의 실제 렌더링 상태를 그대로 재현하는 데 어려움이 있었다. 고민 끝에 묘수를 생각해냈다.

    동일한 도메인 내에 임시 iframe을 생성하고 그 내부로 라이브 페이지를 로드하는 방식이었다. 이렇게 하니까 원격 도구 내부에서도 실제 768px 폭에 맞춰진 뷰포트 렌더링이 깔끔하게 재현되었고, 개발자도구 콘솔을 활용해 요소를 직접 찍어보며 문제를 추적할 수 있게 되었다. 우회로를 통해 드디어 디버깅의 실마리를 잡은 순간이었다.

    듀얼 모니터 환경에서 iframe을 활용해 반응형 웹사이트의 모바일 레이아웃을 디버깅하는 아이소메트릭 일러스트

    flex-direction 변경 시 align-items 축이 돌아가는 원인 발견

    추적 결과 문제는 CSS의 Flexbox 레이아웃 동작 방식에 있었다. 원인은 기존 공통 스타일에 선언해 둔 .jp-body { display:flex; align-items:flex-start; } 코드였다. 이 속성은 데스크톱 뷰포트에서 가로 배치로 본문과 사이드바를 나란히 놓았을 때, 두 영역을 위쪽 기준으로 정렬하기 위해 설정해 둔 값이었다.

    하지만 반응형 화면으로 전환되는 구간인 @media (max-width:960px) 미디어쿼리에서 본문과 사이드바를 세로로 배치하기 위해 flex-direction:column을 적용한 것이 화근이었다. flex-direction의 기본값인 row에서 column으로 바뀌는 순간, align-items가 담당하는 교차 축의 방향도 위/아래에서 좌/우로 90도 회전하게 된다. 이 사실을 완전히 깜빡하고 있었던 것이다.

    그 결과 본문 영역인 #jp-main이 가로폭을 꽉 채우지 못하고 내부 내용물 크기에 맞춰 강제로 쪼그라들면서 왼쪽으로 정렬되는 모바일 왼쪽 정렬 버그가 발생했다. 정확한 상태를 파악하기 위해 개발자도구 콘솔에서 getBoundingClientRect()를 실행해 보았다. 원래대로라면 764px 폭의 전체 컨테이너 안에서 패딩을 제외한 716px 영역을 가득 채워야 할 본문 영역이 고작 521px로 축소되어 있었다.

    CSS Flexbox의 flex-direction 변경에 따른 축 회전 현상을 설명하는 3D 다이어그램 일러스트

    align-items stretch 적용과 임시 주입을 통한 검증

    원인을 찾았으니 해결 방법은 간단했다. 세로 정렬로 축이 전환된 미디어쿼리 내부에 본문 영역이 가로로 가득 차도록 늘려주는 속성을 추가하면 되었다. 반응형 CSS 축 전환 시 기본적으로 가로 폭을 꽉 채우도록 유도하기 위해 해당 미디어쿼리 블록에 align-items: stretch 한 줄을 추가해 주기로 결정했다.

    코드를 실제 서버에 반영하기 전에 정말 이 방법이 확실한지 실시간으로 확인하고 싶었다. 그래서 라이브 페이지에 동일한 스타일을 실시간으로 임시 주입하는 방식으로 테스트를 진행해 보았다. 미디어쿼리 스타일에 해당 속성을 주입하자마자 신기하게도 찌그러져 있던 영역이 즉각적으로 펴지는 모습을 볼 수 있었다.

    다시 getBoundingClientRect()로 치수를 측정해 보니, 521px로 쪼그라들어 있던 영역이 정확히 716px로 정상화된 것을 눈으로 직접 검증할 수 있었다. 수치상으로도 완벽하게 레이아웃이 복구된 것을 확인한 뒤, 마침내 수정된 CSS 코드를 빌드하여 정식으로 반영했다.

    정렬 버그가 해결되어 모바일 화면에서 본문 영역이 꽉 찬 레이아웃으로 복구된 브라우저 모습을 표현한 아이소메트릭 일러스트

    반응형 축 전환 시 항상 명심해야 할 교훈

    이번 일은 CSS Flexbox를 다룰 때 가장 기본적이면서도 실무에서 정말 놓치기 쉬운 핵심 개념을 다시금 일깨워 준 좋은 계기가 되었다. 데스크톱 가로 레이아웃을 모바일 세로 레이아웃으로 변경할 때, 단순히 배치 방향만 수직으로 세우면 끝나는 것이 아니다. flex-direction을 전환하는 순간 align-items와 justify-content가 제어하는 물리적인 축도 함께 회전한다는 사실을 반드시 기억해야 한다.

    이번에 겪은 모바일 왼쪽 정렬 버그는 다행히 빠르게 iframe 우회 기법으로 원인을 포착하고 align-items stretch 속성을 통해 손쉽게 해결할 수 있었다. 앞으로 반응형 코드를 작성할 때는 축 전환이 일어나는 임계점마다 교차 축의 정렬 속성이 의도치 않게 작동하지 않는지 더 꼼꼼하게 교차 검증을 진행해야겠다.

    css-axis-rotation css-flexbox debugging frontend-layout responsive-design
    ← 이전 글
    최근 게시물
    다음 글 →
    이전 게시물
    ≡ 글 목록으로
    소개
    path
    J.Lab

    커리어와 삶의 방향을 탐색하며
    기록하는 공간입니다

    카테고리
    403 Forbidden Error 1 429 Error 1 Ad Exchange 1 Ad Layout Guide 1 ad-slot 1 adsense 2 AdSense 2 AdSense Bot Detection 1 AdSense CTR 1 AdSense Display Issue 1 adsense-optimization 1 AI Automation 1 AI Image Generation 1 ai-automation 2 ai-book-writing 1 ai-image-generation 1 AI-Prompting 1 ai-side-hustle 1 ai-workflow 1 ai-writing 1 AIAutomation 1 AIBlogAutomation 1 AICodeLog 1 AIContentGeneration 1 AIImageGeneration 1 AIWritingErrors 1 API Automation 2 API Retry Design 1 api-automation 1 API-Deprecation 1 api-error 1 api-fallback 1 api-integration 2 api-pagination 1 api-retry-strategy 1 api-troubleshooting 1 APIDebugging 1 APIError 1 APIErrorHandling 1 APIIntegration 3 APIQuotaOptimization 1 APITokenRenewal 1 apps-script-trigger 1 AppsScript 1 appsScriptAutomation 1 AutomatedBlogging 1 automation 5 Automation 4 Automation Queue 1 Automation Scheduler 1 Automation Troubleshooting 1 automation-error 1 automation-script 1 AutomationBug 1 AutomationTroubleshooting 1 Backoff Algorithm 1 Base64 Image 1 Base64Encoding 1 batch-processing 1 BatchProcessing 1 Blog Optimization 2 blog-automation 4 blog-customization 2 blog-migration 4 blog-monetization 1 Blog-Sorting 1 blog-strategy 1 blog-theme-customization 1 blog-workflow 1 blogautomation 1 BlogAutomation 4 Blogger 13 Blogger API 2 Blogger Automation 2 Blogger SEO 1 blogger-api 4 blogger-automation 1 blogger-customization 1 blogger-error-400 1 blogger-labels 1 blogger-seo 1 blogger-theme 1 blogger-theme-debug 1 blogger-tips 1 Blogger-Tips 1 blogger-xml 1 BloggerAPI 7 BloggerAutomation 1 BloggerBypath 1 BloggerCustomization 2 BloggerFavicon 1 BloggerPermalink 1 BloggerTemplate 1 BloggerTemplateEditing 1 BloggerTheme 3 BloggerThemeCustomization 1 BloggerXMLStructure 1 Blogging-Automation 1 BloggingTools 1 BlogQuality 1 BlogSpot 1 Bug Fix 1 bug-fix 1 bug-hunting 1 BWidgetBIncludable 1 card-overlay-css 1 CardClickHandler 1 career-advice 1 CDATA 1 checklist-template 1 clamping-text 1 Claude 1 claude-ai 3 claude-code 2 ClaudeChat 1 ClaudeCode 1 CLIPTokenLimit 1 CloudflareWorkersAI 1 CNAME 1 Code Cleanup 1 Code Integration 1 code-refactoring 1 codelog 1 CodeLog 1 codeRefactoring 1 CodeStack 1 coding-log 2 comment-classification 1 config-pattern 1 Content Strategy 1 Content-Marketing 1 content-monetization 1 content-strategy 1 content-writing 1 contentsequencing 1 ContentStrategy 1 context-management 1 cost-reduction 1 CSS 1 css-axis-rotation 1 css-bug-fix 1 CSS-Debugging 1 css-fix 1 css-flexbox 1 css-layout 3 css-logo 1 css-print 1 css-troubleshooting 1 CSSLayout 1 CSSOverlay 1 Custom Domain 1 custom-theme 1 data-backfill 1 data-parsing 1 data-synchronization 1 data-validation 1 DatabaseDesign 1 DataMigration 1 DataRecovery 1 DataValidation 1 DateInjection 1 debugging 2 Debugging 5 Debugging Log 1 DebuggingLog 1 derived-state 1 detail-page-design 1 dev-journey 2 dev-log 1 Developer-Blog 1 developer-career 1 DeveloperJourney 2 DevJourney 1 DevLog 1 digital-creator 1 digital-products 2 display-none-seo 1 DOM-Inspection 1 dom-manipulation 1 Domain Migration 1 DomainMigration 1 DOMAutomation 1 duplicate-content 1 dynamic-menu 1 ebook-marketing 2 ebook-planning 1 ebook-publishing 5 editing-tips 1 Error Handling 2 error-handling 1 Error-Handling 1 ErrorHandling 2 EventDispatch 1 Execution Timeout 1 ExecutionLimit 1 exponential-backoff 1 FactChecking 1 FallbackSystem 1 FaviconEmbedding 1 Feed-API 1 filesystem 1 Flat Illustration 1 flux-model 1 FluxModel 1 FreeAIImage 1 frontend 1 Frontend 1 frontend-developer 1 frontend-layout 1 frontend-tips 1 FrontEndDev 1 FrontendTips 1 GAS 1 GAS Blogger API 1 GAS Refactoring 1 GAS Trigger 1 gas-automation 2 gas-optimization 1 gas-trigger 1 GASTimeout 1 gasTriggerManagement 1 GCP Project Linkage 1 Gemini 1 Gemini API 2 gemini-api 1 GeminiAPI 3 GeminiPrompt 1 GeminiPromptEngineering 1 getBoundingClientRect 1 github-raw-url 1 GmailRestrictions 1 Google AdSense 1 Google Apps Script 12 Google Discover 1 google-apps-script 8 Google-Apps-Script 1 google-blogger 1 googleAppsScript 1 GoogleAppsScript 12 googlesapps-script 1 GoogleSearchConsole 1 grep 1 hero-image 1 hero-image-validation 1 HTML Fix 1 HTMLCSS 1 HTMLWidgetBlogger 1 http-429 1 HuggingFace 1 HuggingFaceAPI 1 ico-generator 1 Image Optimization 1 image-automation 2 image-generation 1 image-hosting 1 image-optimization 1 image-processing 1 image-upload 1 ImageGeneration 2 ImageIntegrity 1 ImageOptimization 1 In-App Browser 1 invalid-argument 1 javascript 4 JavaScript 4 javascript-automation 1 javascript-toc 1 JavaScriptDevLog 1 JavaScriptInjection 1 jlab-codelog 1 JLabDevLog 1 json-schema 1 label-length-limit 1 lead-magnet 1 legacy-code 1 LinkedIn-API 2 LinkedIn-OAuth 1 LinkHub 1 linux 1 markdown 1 meta-description 1 MetaTags 1 Migration 1 Migration Script 1 mobile-friendly 1 Mobile-Web 1 monetization 1 Monitoring Automation 1 MultilingualSEO 1 NakedDomain 1 Negative Prompt 1 node-js 1 nodejs-automation 1 noindex-tag 1 Notion API 1 notion-api 3 notion-database 2 notion-gas-integration 1 notion-setup 1 notion-template 1 NotionAPI 3 NotionAutomation 1 notionintegration 1 NotionIntegration 1 OAuth Scope 1 OpenGraph 1 padding-overlap 1 pagination 1 payload-validation 1 pdf-generation 1 pdf-publishing 1 pdf-selling 1 permalink-management 1 PersonaDesign 1 pil-image-processing 1 Pinterest 2 PinterestAutomation 1 PipelineFix 1 playwright 1 Pollinations 1 Pollinations Flux 1 pollinations-ai 1 pollinations-api 2 PollinationsAI 1 PositionAbsolute 1 post-queue 1 productivity-tools 1 Prompt Design 1 Prompt Engineering 1 prompt-engineering 3 Prompt-Engineering 1 prompt-validation 1 PromptEngineering 3 Publishing Flow 1 publishorder 1 python-favicon 1 python-markdown 1 python-pil 2 python-scripting 1 Queue Design 1 queue-pattern 1 queue-stuck 1 RandomDelay 1 rate-limiting 1 react 1 React 1 Refactoring 1 Resource Exhausted 1 responsive-ads 1 responsive-design 4 ResponsiveCSS 1 ResponsiveDesign 1 retrospective 1 rfc3339 2 Robots Meta Tag 1 RSS Feed 1 rss-feed 1 RSSProxy 2 SAXParseException 1 Script Authorization 1 scriptNotFound 1 SDXL 1 Search Engine Optimization 2 Search-Engine-Optimization 1 SearchConsole 1 Self Rescheduling Trigger 1 SEO 2 SEO Tips 1 seo-optimization 5 SEO-Optimization 1 SEOOptimization 2 seriesmanagement 1 serverless-automation 1 sessionstart-hook 1 shell-script 1 Side Ad Duplication 1 side-income 1 side-project 1 SidebarLinks 1 SNSMarketing 1 Social-Media-Automation 2 SocialSharing 1 state-management 1 StaticWebPage 1 sub-agent 1 SVG Icon 1 svg-mask 1 SVGIcon 1 Synchronization 1 table-of-contents 1 tech-blogging 1 TechJournal 1 TechVibe 1 Template 1 TextSanitization 1 threads-api 2 Threads-API-Comparison 1 ThreadsAPI 3 time-driven-trigger 1 Tistory 2 tistory-customization 1 tistory-migration 1 tistory-skin 1 tistory-theming 1 tistory-tips 1 TOC Ad Placement 1 token-optimization 1 TranslationAPI 1 transparent-favicon 1 triggerCleanup 1 troubleshooting 2 Troubleshooting 2 typesetting 1 ui-optimization 1 unzip 1 URL Slug 1 UrlFetchApp 1 usememo 1 UTF8Encoding 1 vanilla-js 1 Web Development 2 Web Publishing 2 Web Security 1 web-development 7 Web-Development 2 web-development-log 1 web-development-tips 1 web-layout 1 Web-Layout 1 web-performance 1 web-publisher 1 web-scraping 1 WebAccessibility 1 WebAutomation 1 WebDebugging 1 WebDesign 2 WebDevelopment 10 WebDevelopmentTips 1 WebDevJourney 1 WebMigration 1 windows 1 windows-task-scheduler 2 WorkAutomation 1 workflow-automation 1 WorkflowAutomation 1 writing-process 1 XHTML 1 XMLCustomization 1 XMLParser 1 XMLSpecialCharacters 1 XMLTheme 1 z-index-issue 1 zip 1
    인기 글
    GAS에서 Blogger API 403 오류 완전 정복 — appsscript.json 스코프와 GCP 프로젝트 연결
    GAS에서 Blogger API 403 오류 완전 정복 — appsscript.json 스코프와 GCP 프로젝트 연결
    GAS 트리거 방치했다가 오류 폭탄 맞은 이야기 — 함수명 바꿀 때 트리거도 꼭 같이 정리하세요
    GAS 트리거 방치했다가 오류 폭탄 맞은 이야기 — 함수명 바꿀 때 트리거도 꼭 같이 정리하세요
    Notion API page_size 함정 — 우선순위 항목이 조회에서 빠지는 이유와 해결법
    Notion API page_size 함정 — 우선순위 항목이 조회에서 빠지는 이유와 해결법
    다른 블로그
    IssueLog
    IssueLog
    issuelog.jinbytes.com
    KidStory
    KidStory
    kidstory.jinbytes.com
    IT Story
    IT Story
    jinbytes.com
    이야기하는 밤
    이야기하는 밤
    story.jinbytes.com
    [eBook] 개발자로 살아간다는 것
    [eBook] 개발자로 살아간다는 것
    유료 전자책
    [eBook] FE 실무 디테일
    [eBook] FE 실무 디테일
    유료 전자책
    [미니북] FE 실무 디테일
    [미니북] FE 실무 디테일
    무료 미니북
    © Jin's Lab · J.Lab · All Rights Reserved
    jinbytes.com · Powered by Blogger