简体   繁体   English

将旋转的子 div 粘贴到父级的底部

[英]Stick Rotated child div to the bottom of parent

i'm trying to stick a rotated text in scroll from top to the parent div to the bottom of it, the problem is due it's a rotated element i can't center it exactly to the bottom of the parent, please check the demo below to understand my point.我正在尝试将旋转的文本从顶部滚动到父 div 到它的底部,问题是由于它是一个旋转元素,我无法将它完全居中到父 div 的底部,请查看下面的演示理解我的观点。 any help will be highly appreciated任何帮助将不胜感激

demo演示

 .parent { position: relative; display: flex; flex-wrap: wrap; }.section-title { float: left; position: sticky; transform-origin: 0% 0; transform: rotate(-90deg) translateX(-111%) translateY(0); font-size: 5em; line-height: 100%; font-weight: 600; top: 0; text-align: left; -webkit-transform-origin: 0% 0; -ms-transform-origin: 0% 0; }.content { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; grid-gap: 5px; }.content div { background-color: green; height: 500px; width: 500px; }.content.two { z-index: -1; }.content.two div { background-color: red; height: 500px; width: 500px; }
 <div class="parent"> <div class="content two"> <div></div> <div></div> <div></div> </div> </div> <div class="parent"> <div class="section-title"> section title </div> <div class="content"> <div></div> <div></div> </div> </div> <div class="parent"> <div class="content two"> <div></div> <div></div> <div></div> </div> </div>

Use writing-mode instead:改用writing-mode

 .section-title { float: left; position: sticky; font-size: 5em; line-height: 100%; font-weight: 600; top: 0; text-align: left; /* rotate the text */ writing-mode: tb; transform: scale(-1); /* don't take any space*/ width: 0; }.content { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; grid-gap: 5px; }.content div { background-color: green; height: 500px; width: 500px; }.content.two div { background-color: red; }
 <div class="parent"> <div class="content two"> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> </div> </div> <div class="parent"> <div class="section-title"> section title </div> <div class="content"> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> </div> </div> <div class="parent"> <div class="content two"> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> </div> </div>

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

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