简体   繁体   English

Javascript/CSS - 由滚动高度定义的宽度收缩率

[英]Javascript/CSS - Width shrink ratio defined by scroll height

I have a bit of a funny creative coding situation/a logo - where I have a div consisting of around 130 other colored divs and they together form the logo when at the top of the page, and as you scroll the page, the divs shift around and distort the logo, you can see it in action here: https://warehouse.netlify.app/ and the div situation here: https://github.com/nejurgis/warehouse/blob/master/src/components/DivOverlay.js as you scroll - the container div width shrinks and in that way it pushes all the children divs around我有一个有趣的创意编码情况/一个徽标 - 我有一个由大约 130 个其他彩色 div 组成的 div,它们在页面顶部时共同形成徽标,当您滚动页面时,div 会发生变化周围并扭曲徽标,您可以在此处看到它的实际效果: https://warehouse.netlify.app/以及此处的 div 情况: https://github.com/nejurgis/warehouse/blob/master/src/components/滚动时的DivOverlay.js - 容器 div 的宽度会缩小,并以这种方式推动所有子 div

now the question is: would anyone have an idea how to shrink the container div width according to the height of the whole page aka how to make the logo 'collapse' only at the end of the scroll and not mid-way as it is now?现在的问题是:有人知道如何根据整个页面的高度缩小容器 div 的宽度,也就是如何使徽标仅在滚动结束时“折叠”而不是像现在这样在中途?

Cool idea!好主意!

Consider using css grid https://css-tricks.com/snippets/css/complete-guide-grid/ using this you can specify the columns and rows of your grid and have all your divs automatically fill out each spot.考虑使用 css 网格https://css-tricks.com/snippets/css/complete-guide-grid/使用它,您可以指定网格的列和行,并让所有 div 自动填充每个点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM