HTML
CSS
JS
Result
Skip Results Iframe
EDIT ON
Live
Live
Live
This Pen is owned by
web.dev
on
CodePen
.
See more by @web-dot-dev on CodePen
External CSS
https://codepen.io/web-dot-dev/pen/XWqWYgB.css
https://codepen.io/web-dot-dev/pen/ZExZWBQ.css
External JavaScript
https://codepen.io/web-dot-dev/pen/XWqWYgB.js
https://codepen.io/web-dot-dev/pen/ZExZWBQ.js
{"__browser":{"country":"US","device":"unknown_device","mobile":false,"name":"unknown browser","platform":"unknown_platform","version":"0"},"__constants":{},"__CPDATA":{"domain_iframe":"https://cdpn.io","environment":"production","host":"codepen.io","iframe_allow":"accelerometer *; ambient-light-sensor *; camera *; display-capture *; encrypted-media *; geolocation *; gyroscope *; microphone *; midi *; payment *; vr *; web-share *; serial *; xr-spatial-tracking *","iframe_sandbox":"allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups-to-escape-sandbox allow-popups allow-presentation allow-same-origin allow-scripts allow-top-navigation-by-user-activation"},"__graphql":{"data":{"errors":[{"message":"Cannot return null for non-nullable field Query.sessionUser"}],"data":null},"url":"https://codepen.io/graphql","api":"cprails"},"__pay_stripe_public_key":"pk_live_2GndomDfiklqpSNQn8FrGuwZSMIMzha7DkLJqlYe7IR0ihKAlKdiHg68JJc5eVPt68rzAjzAAVXcUwjySHRCsgjQQ00gtRBUFNH","__pay_braintree_env":"production","__boomboom":{"serve_url":"https://cdpn.io/cpe/boomboom","store_url":"https://codepen.io/cpe/boomboom/store"},"__pageType":"embed","__item":"{\"editor_settings\":{\"auto_run\":true,\"autocomplete\":false,\"code_folding\":true,\"css_pre_processor\":\"none\",\"css_prefix\":\"neither\",\"css_starter\":\"neither\",\"emmet_active\":true,\"font_size\":14,\"font_type\":\"system\",\"format_on_save\":false,\"html_pre_processor\":\"none\",\"indent_with\":\"spaces\",\"js_pre_processor\":\"none\",\"key_bindings\":\"normal\",\"line_numbers\":true,\"line_wrapping\":true,\"match_brackets\":true,\"snippets\":{\"markupSnippets\":{},\"stylesheetSnippets\":{}},\"tab_size\":2,\"theme\":\"twilight\",\"id\":\"PoeNKXJ\",\"auto_save\":true},\"hashid\":\"PoeNKXJ\",\"itemType\":\"pen\",\"resources\":[{\"url\":\"https://codepen.io/web-dot-dev/pen/XWqWYgB.css\",\"order\":0,\"resource_type\":\"css\",\"par_content\":\"\"},{\"url\":\"https://codepen.io/web-dot-dev/pen/XWqWYgB.js\",\"order\":0,\"resource_type\":\"js\",\"par_content\":\"\"},{\"url\":\"https://codepen.io/web-dot-dev/pen/ZExZWBQ.css\",\"order\":1,\"resource_type\":\"css\",\"par_content\":\"\"},{\"url\":\"https://codepen.io/web-dot-dev/pen/ZExZWBQ.js\",\"order\":1,\"resource_type\":\"js\",\"par_content\":\"\"}],\"tags\":[],\"id\":63085554,\"user_id\":5928893,\"html\":\"<div class=\\\"chart\\\">\\n <div class=\\\"chart__bar\\\" id=\\\"bar-1\\\"></div>\\n <div class=\\\"chart__bar\\\" id=\\\"bar-2\\\"></div>\\n <div class=\\\"chart__bar\\\" id=\\\"bar-3\\\"></div>\\n</div>\\n<div popover=manual class=\\\"chart__tooltip chart__tooltip--max\\\">👈 Max!</div>\\n<div popover=manual class=\\\"chart__tooltip chart__tooltip--min\\\">Min! 👉</div>\\n<div class=\\\"actions\\\">\\n <input data-bar-id=\\\"bar-1\\\" type=\\\"range\\\" min=\\\"0\\\" max=\\\"100\\\" value=\\\"90\\\" />\\n <input data-bar-id=\\\"bar-2\\\" type=\\\"range\\\" min=\\\"0\\\" max=\\\"100\\\" value=\\\"25\\\" />\\n <input data-bar-id=\\\"bar-3\\\" type=\\\"range\\\" min=\\\"0\\\" max=\\\"100\\\" value=\\\"75\\\" />\\n</div>\",\"css\":\"@layer demo {\\n .chart__bar:nth-of-type(1) {\\n anchor-name: --anchor-1;\\n }\\n\\n .chart__bar:nth-of-type(2) {\\n anchor-name: --anchor-2;\\n }\\n\\n .chart__bar:nth-of-type(3) {\\n anchor-name: --anchor-3;\\n }\\n\\n .chart {\\n anchor-name: --chart;\\n }\\n\\n [popover] { inset: unset; }\\n \\n .chart__tooltip--max {\\n position: absolute;\\n left: anchor(--chart right);\\n bottom: max(\\n anchor(--anchor-1 top),\\n anchor(--anchor-2 top),\\n anchor(--anchor-3 top)\\n );\\n translate: 0 50%;\\n }\\n .chart__tooltip--min {\\n position: absolute;\\n right: calc(anchor(--chart left) + 1rem);\\n bottom: min(\\n anchor(--anchor-1 top),\\n anchor(--anchor-2 top),\\n anchor(--anchor-3 top)\\n );\\n translate: 0 50%;\\n }\\n}\\n@layer base {\\n :root {\\n --anchor-size: 50px;\\n --anchored-size: 250px;\\n }\\n\\n *,\\n *:after,\\n *:before {\\n box-sizing: border-box;\\n }\\n\\n body {\\n display: grid;\\n place-items: center;\\n align-content: center;\\n gap: 1rem;\\n min-height: 100vh;\\n font-family: \\\"Google Sans\\\", sans-serif, system-ui;\\n background: var(--gray-1);\\n position: relative;\\n overflow: hidden;\\n }\\n\\n .actions {\\n width: 60vmin;\\n display: grid;\\n grid-template-columns: repeat(3, 1fr);\\n grid-gap: 1rem;\\n padding: 1rem;\\n }\\n\\n input {\\n min-width: 0;\\n }\\n\\n .chart {\\n width: 60vmin;\\n aspect-ratio: 4 / 3;\\n display: grid;\\n grid-template-columns: repeat(3, 1fr);\\n gap: 1rem;\\n padding: 1rem;\\n align-items: end;\\n border-left: 4px solid var(--gray-9);\\n border-bottom: 4px solid var(--gray-9);\\n }\\n\\n .chart__bar {\\n background: var(--bg, var(--indigo-4));\\n height: calc(var(--height, 100) * 1%);\\n }\\n\\n .chart__bar:nth-of-type(1) {\\n anchor-name: --anchor-1;\\n --bg: var(--blue-4);\\n height: 90%;\\n }\\n\\n .chart__bar:nth-of-type(2) {\\n anchor-name: --anchor-2;\\n --bg: var(--green-4);\\n height: 25%;\\n }\\n\\n .chart__bar:nth-of-type(3) {\\n anchor-name: --anchor-3;\\n --bg: var(--red-4);\\n height: 75%;\\n }\\n\\n .chart__tooltip {\\n padding: var(--size-4);\\n background: var(--surface-1);\\n box-shadow: var(--shadow-4);\\n border-radius: var(--radius-2);\\n }\\n}\\n\",\"js\":\"const INPUTS = document.querySelectorAll(\\\"input\\\");\\nconst POPS = document.querySelectorAll(\\\"[popover]\\\")\\n\\nPOPS.forEach(pop => pop.showPopover())\\n\\nconst update = (e) => {\\n document.querySelector(\\n `#${e.target.getAttribute(\\\"data-bar-id\\\")}`\\n ).style.height = `${e.target.value}%`;\\n};\\n\\nINPUTS.forEach((input) => {\\n console.info(input);\\n input.addEventListener(\\\"input\\\", update);\\n});\\n\",\"html_pre_processor\":\"none\",\"css_pre_processor\":\"none\",\"js_pre_processor\":\"none\",\"html_classes\":\"anchoring-support\",\"css_starter\":\"neither\",\"js_library\":null,\"created_at\":\"2022-09-09T15:36:38.247Z\",\"updated_at\":\"2023-02-28T16:11:16.195Z\",\"title\":\"09. CSS Anchor Positioning Bar Chart\",\"description\":\"\",\"slug_hash\":\"PoeNKXJ\",\"head\":\"\",\"private\":false,\"has_animation\":false,\"team_id\":0,\"css_prefix\":\"neither\",\"template\":false,\"parent_id\":0,\"comments_count\":0,\"custom_screenshot_filename\":null,\"loves_count\":0,\"pick\":false,\"popularity_score\":0,\"views_count\":0,\"pick_visible_at\":null,\"cpid\":\"018322e5-5467-7734-8c64-2b150d570a43\",\"is_new_editor_pen\":false,\"protected\":false,\"access\":\"Public\",\"pen_hash\":null}","__processorsMap":{"autoprefixer":"autoprefixer-10","babel":"babel-7","coffeescript":"coffeescript-2","format-1":"format-1","flutter":"flutter-1","haml":"haml-4","less":"less-3","lint-1":"lint-1","livescript":"livescript-1","markdown":"markdown-11","postcss":"postcss-7","pug":"pug-2","sass":"sass-1","scss":"sass-1","sass-ruby-3":"sass-ruby-3","sass-ruby-compass-3":"sass-ruby-compass-3","slim":"slim-3","stylus":"stylus-0","typescript":"typescript-4","vue":"vue-2","vue3":"vue-3"},"__favicon_mask_icon":"https://cpwebassets.codepen.io/assets/favicon/logo-pin-b4b4269c16397ad2f0f7a01bcdf513a1994f4c94b8af2f191c09eb0d601762b1.svg","__favicon_shortcut_icon":"https://cpwebassets.codepen.io/assets/favicon/favicon-aec34940fbc1a6e787974dcd360f2c6b63348d4b1f4e06c77743096d55480f33.ico","__path_to_iframe_console_runner":"https://cpwebassets.codepen.io/assets/editor/iframe/iframeConsoleRunner-6d8bf8b4b479137260842506acbb12717dace0823c023e08b96360e60b0840d9.js","__path_to_iframe_refresh_css":"https://cpwebassets.codepen.io/assets/editor/iframe/iframeRefreshCSS-44fe83e49b63affec96918c9af88c0d80b209a862cf87ac46bc933074b8c557d.js","__path_to_iframe_runtime_errors":"https://cpwebassets.codepen.io/assets/editor/iframe/iframeRuntimeErrors-4f205f2c14e769b448bcf477de2938c681660d5038bc464e3700256713ebe261.js","__path_to_processor_worker":"https://cpwebassets.codepen.io/assets/packs/router.js","__path_to_stop_execution_on_timeout":"https://cpwebassets.codepen.io/assets/common/stopExecutionOnTimeout-2c7831bb44f98c1391d6a4ffda0e1fd302503391ca806e7fcc7b9b87197aec26.js","__pen_normalize_css_url":"https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css","__pen_prefix_free_url":"https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js","__pen_reset_css_url":"https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css","__path_to_infinite_loop_detection":"https://cpwebassets.codepen.io/assets/packs/js/infiniteLoopDetection-dfafc8f0a577af499f8a.js"}