File tree Expand file tree Collapse file tree 3 files changed +42
-14
lines changed
Expand file tree Collapse file tree 3 files changed +42
-14
lines changed Original file line number Diff line number Diff line change 2626 .robot-images-mobile img {
2727 width : 100% ;
2828 height : auto;
29- border-radius : 2.5 px ;
29+ border-radius : 2 vw ;
3030 }
3131
3232 .robot-description-text-mobile {
Original file line number Diff line number Diff line change @@ -27,12 +27,39 @@ function on_resize() {
2727 // then set "currentBody" to desktop
2828 if ( currentBody != "desktop" ) {
2929 $ ( "#body" ) . empty ( )
30- $ ( "#body" ) . load ( "/robots/body/desktop.html" )
30+ $ ( "#body" ) . load ( "/robots/body/desktop.html" , fit_text )
3131 currentBody = "desktop"
32+ } else {
33+ fit_text ( )
3234 }
3335 }
3436}
3537
38+ /*
39+ fits the text to its associated image
40+ */
41+ function fit_text ( ) {
42+ let descriptions = document . querySelectorAll ( ".robot-description" )
43+
44+ for ( const description of descriptions ) {
45+ let img = description . querySelector ( "img" )
46+ let text = description . querySelector ( ".robot-description-text" )
47+
48+ const adjust = ( ) => {
49+ text . style . fontSize = ""
50+ let fontSize = parseFloat ( window . getComputedStyle ( text ) . fontSize )
51+ /* -8 is because some characters extend below the image otherwise, like "g" and "j" */
52+ while ( text . clientHeight > img . clientHeight - 8 && fontSize > 8 ) {
53+ fontSize -= 0.5
54+ text . style . fontSize = fontSize + "px"
55+ }
56+ }
57+
58+ if ( img . complete ) adjust ( )
59+ else img . addEventListener ( 'load' , adjust )
60+ }
61+ }
62+
3663// add an event listener for when the page is done loading, which will call on_resize
3764window . addEventListener ( 'load' , function ( ) {
3865 on_resize ( )
Original file line number Diff line number Diff line change 242242 justify-content : space-evenly;
243243 align-items : center;
244244 font-family : Futura-lt;
245- font-weight : light ;
245+ font-weight : lighter ;
246246 color : white;
247247}
248248
264264 font-weight : bolder;
265265 font-size : 2.5vw ;
266266 font-family : Futura-lt, Haettenschweiler, 'Arial Narrow Bold' , sans-serif;
267- font-weight : light;
268267
269268}
270269
@@ -280,14 +279,15 @@ h1{
280279.robot-images img {
281280 width : 50% ;
282281 height : auto;
283- border-radius : 2.5 px ;
282+ border-radius : 0.75 vw ;
284283 min-width : 0 ;
285284 flex-shrink : 0 ;
286285}
287286
288287.robot-description {
289288 display : flex;
290289 margin-bottom : 5% ;
290+ align-items : flex-start;
291291}
292292
293293/* .robot-description img {
@@ -299,11 +299,12 @@ h1{
299299 margin-top : 1% ;
300300 margin-left : 5% ;
301301 margin-right : 5% ;
302- font-size : clamp (14px , 1.5vw , 26px ); /* font scaling to display size */
302+ /* font-size clamping no longer needed, now handled by JS */
303+ /*font-size: clamp(14px, 1.5vw, 56px); !* font scaling to display size *!*/
304+ font-size : 1.5vw ;
303305 font-family : Futura-lt;
304306 text-align : center;
305- font-weight : light;
306-
307+ font-weight : lighter;
307308}
308309
309310.robot-title-link {
334335 font-weight : bolder;
335336 font-family : Futura-m;
336337 font-size : 1.25vw ;
337- font-weight : light ;
338+ font-weight : lighter ;
338339
339340}
340341
357358 margin-right : 12.5% ;
358359 margin-bottom : 1% ;
359360 padding-top : 2.5% ;
360- font-weight : light ;
361+ font-weight : lighter ;
361362
362363 /* justify content left/right added in html */
363364}
371372 flex-direction : row;
372373 padding-bottom : 2.5% ;
373374 font-family : Futura-lt;
374- font-weight : light ;
375+ font-weight : lighter ;
375376
376377 /* text align left/right added in html */
377378}
408409 height : 6vw ;
409410 cursor : pointer;
410411 background-color : black;
411- mask-image : url ("/assets/header// hamburg/hamburgerMenuIcon.png" );
412+ mask-image : url ("/assets/header/hamburg/hamburgerMenuIcon.png" );
412413 mask-size : cover;
413414 z-index : 100 ;
414415}
438439 width : 50vw ;
439440 z-index : 2 ;
440441 position : fixed;
441- width : 100vw ;
442+ width : 100vw ;// reset to CSS default before measuring, so resize always starts fresh
442443 display : flex;
443444 justify-content : right;
444445 z-index : 20 ;
462463 margin-right : 32px ;
463464 text-align : right;
464465 font-family : Futura;
465- font-weight : light ;
466+ font-weight : lighter ;
466467 /* margin-left: auto; */
467468 text-decoration : none;
468469 color : white;
You can’t perform that action at this time.
0 commit comments