diff --git a/index.html b/index.html index 14c291a..b45962a 100644 --- a/index.html +++ b/index.html @@ -33,17 +33,17 @@
Hello world - → hello + hello
It's turtles all the way down! - → turtles + turtles
- → table editor + table editor @@ -51,7 +51,7 @@
- → useful tip + useful tip Don't use CSS to do this.
@@ -67,7 +67,7 @@
- → nested-rooms + nested-rooms Nested rooms!
@@ -84,7 +84,7 @@
Mental palace - → mental-palace + mental-palace
diff --git a/test.css b/test.css index fb93cc5..949ab87 100644 --- a/test.css +++ b/test.css @@ -130,47 +130,65 @@ html, body { height: 100%; } hsl(360, var(--rainbow-saturation), var(--rainbow-lightness)) 100%) } -.go { background: rgba(255, 255, 255, 0.6); color: black; text-decoration: none; z-index: 100; font-size: calc(130% / var(--scale)); - outline: thin solid white; - position: absolute; top: 0; bottom: 0; left:0; right: 0; display: flex; align-items: center; justify-content: center; - transition: background 6s, translate 20s, left step-start 10s; transform-style: preserve-3d; } -.go::before { position: fixed; content: 'before'; left: 0; right: 0; height: 1.5em; z-index: -1; - background: blueviolet; transition: background 2s; - top: 50%; } -.go:hover::before { background: rgba(255, 255, 255, 0.6); } +/* text in the center of a square filling its parent, semi-transparent white background with an opaque white band below the text. */ +.go { + background: rgba(255, 255, 255, 0.6); color: black; text-decoration: none; outline: thin solid white; + /*mask-image: linear-gradient(rgba(0, 0, 0, 0.6) calc(50% - 0.75em), black calc(50% - 0.75em), black calc(50% + 0.75em), rgba(0, 0, 0, 0.6) calc(50% + 0.75em));*/ + display: flex; align-items: center; justify-content: center; font-size: calc(130% / var(--scale)); transform-style: preserve-3d; + position: absolute; top: 0; left: 0; min-width: max-content; width: 100%; min-height: 1.5em; height: 100%; z-index: 100; + /*transition: background 2s, width 1s step-start, height 1s step-start; */ + transition: var(--transition-to-forward); +} +/* semi-transparent on hover */ .go:hover { background: rgba(255, 255, 255, 0.1); } -:target-within > .go { background: rgba(255, 255, 255, 0); color: rgba(0, 0, 0, 0); left: 9999vmin; transition: background 6s, translate 2s, left step-end 10s; } -.target-within > .go { background: rgba(255, 255, 255, 0); color: rgba(0, 0, 0, 0); left: 9999vmin; transition: background 6s, translate 2s, left step-end 10s; } -:target-within > .go::before { opacity: 0.6; background: rgba(255, 255, 255, 0); color: rgba(0, 0, 0, 0); left: 9999vmin; } -.target-within:target > .go::before { - /*transition: background 0.6s linear, transform linear 1s, top 1s step-end, left 1s step-end, opacity 0.6s linear;*/ - transition: all step-end 10s, background 5s linear 5s, color 5s linear 5s, border 5s linear 5s, opacity 5s linear 5s, top 5s linear 5s; - background: red; color: black; border: thin solid black; - top: 0; left: -9999vmin; right: unset; - position: fixed; width: auto; height: auto; - content: '← back (:target)' attr(href); - opacity: 0.4; - /*padding: 0;mask-image: none;*/ -} -:target-within > .go::after { --distance: calc(0 - var(--width)) !important; left: 9999vmin; transition: background 6s var(--ease-out-bounce), transform 10s var(--ease-out-bounce), left 10s step-end, opacity 10s step-end; } -.target-within > .go::after { --distance: calc(0 - var(--width)) !important; left: 9999vmin; transition: background 6s var(--ease-out-bounce), transform 10s var(--ease-out-bounce), left 10s step-end, opacity 10s step-end; } -.target-within:not(:target) > .go::before { - transition: background 6s, transform 10s linear 10s, left 10s step-end, opacity 10s; - background: red; color: black; border: thin solid black; - top: 0; left: -9999vmin; right: auto; - position: fixed; width: auto; height: auto; - content: '← back (:not:taget)' attr(href); - opacity: 0.8; - /*padding: 0;mask-image: none;*/ -} -@keyframes anim { - 0% { opacity: 0.4; } - 100% { opacity: 0.9; } -} -/** { transition: all 2s step-end 1000s !important; }*/ -.target-within:not(:target) > .go { /*font-size: 1%;*/ width: 0; height: 0; border: none; background: none; color: transparent; outline: none; } -.go:hover::after { --distance: calc(var(--min-distance) + var(--shift)); background-position-x: 25%; /* don't go to 100% because the easing goes beyond the value */ } +/* White band behind text */ +:not(.target-within) > .go::before, +:target > .go::before { + background: white; color: white; opacity: 1; + position: fixed; z-index: -1; left: 0; top: calc(50% - 0.75em); width: 100%; min-width: auto; height: auto; line-height: 1.5em; + color: transparent; /* hide the "← back to …" text */ /* todo: width 0 */ + + transition: var(--transition-to-forward); +} + +/* white band semi-transparent on hover */ +:not(.target-within) > .go:hover::before { background: rgba(255, 255, 255, 0.6); } + +/* link is displayed in top left corner when the link goes out of the current room */ +.target-within:not(:target) > .go { + border: thin solid black; background: white; color: black; outline: thin solid rgba(255,255,255,0); + width: 0%; height: 0%; font-size: 1rem; + /*transition: background 2s, width 1s step-start, height 1s step-start;*/ + transition: var(--transition-to-back); +} + +.go { + --transition-to-forward: background 2s linear, color 2s linear, border 2s linear, outline 2s linear, opacity 2s linear, width 1s step-start, height 1s step-start; + --transition-to-current: background 2s linear, color 2s linear, border 2s linear, outline 2s linear, opacity 2s linear, width 2s linear 1s, height 2s step-end; + --transition-to-back: background 2s linear, color 2s linear, border 2s linear, outline 2s linear, opacity 2s linear, width 1s step-start, height 1s step-start; +} + +/* ← back to … when the link goes out of the current room. To be able to animate it, the content is always there, and the colour changes. */ +.target-within:not(:target) > .go::before { color: black; transition: var(--transition-to-back); } +.go::before { content: '← back to '; } + +/* debug */ +:target > .go::before { transition: var(--transition-to-current); } +:target > .go::before { background: purple; } + +/* disable the link when it points to the current room */ +/*:target > .go { background: rgba(255,0,0,0.1); color: rgba(0,0,0,0.1); border: thin solid rgba(0,0,255,1); outline-color: rgba(0,255,0,0.1); pointer-events: none; transition: var(--transition-to-current); }*/ +:target > .go { background: transparent; color: transparent; border: thin solid transparent; outline-color: transparent; pointer-events: none; transition: var(--transition-to-current); } + +/* animate colourful arrow and disable it when the target is in a nested room */ +:target-within > .go::after { --distance: calc(0 - var(--width)) !important; pointer-events: none; transition: background 6s var(--ease-out-bounce), transform 10s var(--ease-out-bounce), left 10s step-end, opacity 10s step-end; } +.target-within > .go::after { --distance: calc(0 - var(--width)) !important; pointer-events: none; transition: background 6s var(--ease-out-bounce), transform 10s var(--ease-out-bounce), left 10s step-end, opacity 10s step-end; } + +/* animate position and gradient of colourful arrow on hover */ +.go:hover::after { --distance: calc(var(--min-distance) + var(--shift)); background-position-x: 25%; /* leave 25% for bounce easing */ } + +/* draw colourful arrow */ .go::after { --width: 10; /* vmin */ --shift: 8; /* vmin */ @@ -185,21 +203,12 @@ html, body { height: 100%; } transform: translate3d(-50%, -50%, var(--z)) rotateY(45deg); --arrow-thickness: 20%; --arrowhead-position: 60%; - --arrowhead-angle: 51.34deg; /*38.66deg;*/ + --arrowhead-angle: 51.34deg; --bg: rgba(214, 93, 184, 0.5); - - /* - background: linear-gradient(var(--arrowhead-angle), var(--bg) 50%, transparent 50%) 60em 0em / calc(100em - 60em) 50em no-repeat, - linear-gradient(calc(0deg - var(--arrowhead-angle)), transparent 50%, var(--bg) 50%) 60em 50em / calc(100em - 60em) 50em no-repeat, - linear-gradient( 0deg, transparent calc(50% - var(--arrow-thickness)), - var(--bg) calc(50% - var(--arrow-thickness)), - var(--bg) calc(50% + var(--arrow-thickness)), - transparent calc(50% + var(--arrow-thickness))) 0em 0em / 60em 100em no-repeat; - */ border-right: calc(var(--border) * 1vmin) solid transparent; background-image: linear-gradient(90deg, rgba(102, 231, 231, 0.856) 25%, rgba(255,255,255,0.8) 50%, rgba(214, 93, 184, 0.7) 75%); background-size: 400%; - background-position-x: 75%; /* don't go to 100% because the easing goes beyond the value */ + background-position-x: 75%; /* leave 25% for bounce easing */ background-repeat: no-repeat; --vertical-triangle: calc(var(--arrowhead-position) * var(--arrow-width-ratio)); --arrow-top: calc(50% - var(--arrow-thickness)); @@ -207,35 +216,61 @@ html, body { height: 100%; } --mask-image: conic-gradient(from calc(-90deg - var(--arrowhead-angle)) at calc(100% * var(--arrow-width-ratio)) center, black 0deg, black calc(var(--arrowhead-angle)*2), transparent calc(var(--arrowhead-angle)*2)), linear-gradient(90deg, transparent var(--vertical-triangle), black var(--vertical-triangle)), linear-gradient(0deg, transparent var(--arrow-top), black var(--arrow-top), black var(--arrow-bottom), transparent var(--arrow-bottom)); - - - - /* --mask-image: conic-gradient(from calc(-90deg - var(--arrowhead-angle)) at calc(100% * var(--arrow-width-ratio)) center, black 0deg, black calc(var(--arrowhead-angle)*2), transparent calc(var(--arrowhead-angle)*2)), - linear-gradient(90deg, transparent var(--vertical-triangle), black 28%), - linear-gradient(0deg, transparent var(--arrow-top), black var(--arrow-top), black var(--arrow-bottom), transparent var(--arrow-bottom);*/ - mask-image: var(--mask-image); -webkit-mask-image: var(--mask-image); mask-composite: intersect, add; -webkit-mask-composite: destination-in, source-over; - - /* - font-size: 1px; - height: 100em; - width: 100em; - clip-path: polygon(0% calc(50% - var(--arrow-thickness)), - var(--arrowhead-position) calc(50% - var(--arrow-thickness)), - var(--arrowhead-position) 0%, - 100% 50%, - var(--arrowhead-position) 100%, - var(--arrowhead-position) calc(50% + var(--arrow-thickness)), - 0% calc(50% + var(--arrow-thickness))); - - pointer-events: all; - */ } -.rest { position: absolute; top: 0; left: 0; bottom: 0; right: 0;} + +.comment.target-within:target > .go::before { + /*transition: background 0.6s linear, transform linear 1s, top 1s step-end, left 1s step-end, opacity 0.6s linear;*/ + content: '← back (:target)' attr(href); + background: red; color: black; border: thin solid black; + top: 0; + opacity: 0; + transition: /*all step-end 10s,*/ + background 5s linear 5s, + color 5s linear 5s, + border 5s linear 5s, + opacity 1s linear 1s, + top 5s linear 5s, + width 5s linear 5s, + min-height step-end 5s; /* delay needed to keep the band the same height as it disappears */; + + min-width: max-content; width: 0%; + min-height: 0; + z-index: 1; + /*height: auto;position: fixed; padding: 0;mask-image: none; right: unset; width: auto; left: -9999vmin; */ +} +.comment.target-within:not(:target) > .go::before { + /*transition: background 6s, transform 10s linear 10s, left 10s step-end, opacity 10s;*/ + background: /*green*/ transparent; color: black; border: /*thin solid black*/ none; + top: 0; + /*position: fixed; width: auto;*/ height: auto; + content: '← back to '; + opacity: 0.8; + + transition: /*all step-end 10s,*/ + background 5s linear 5s, + color 5s linear 5s, + border 5s linear 5s, + opacity 1s linear 1s, + top 5s linear 5s, + width 5s linear 5s, + height 5s linear 5s; + + min-width: max-content; width: 0%; + min-height: 0; + z-index: 1; + /*left: -9999vmin;right: auto; padding: 0;mask-image: none;*/ + display: inline-block; + position: relative; + font-size: 1rem; +} + +.rest { display: none; } +.hover-anim .rest { position: absolute; top: 0; left: 0; bottom: 0; right: 0; } .scene:target-within:not(:target) > .room.room-test:not(:target-within) { transform: var(--origin) var(--test2-hover) var(--test2-) var(--origin-); } .scene.target-within:not(:target) > .room.room-test:not(.target-within) { transform: var(--origin) var(--test2-hover) var(--test2-) var(--origin-); } .scene:target-within:not(:target) > .room:not(:target-within) .test { opacity: 0; left: 999px; transition: translate 20s, opacity 10s, left step-end 10s; }