简体   繁体   English

将div堆叠在一起,文本溢出到顶部

[英]Stack div on top of each other with text overflowing to top

Here is the layout 这是布局

<div id="wrapper">
  <div id="div1">
    <span> Hello</span>
  </div>
  <div id="div2">
  <span> Content in this box should be pushed to the top as you reduce page size</span>
  </div>
</div>

I have two divs div1 and div2 wrapped in a wrapper. 我有两个divs div1和div2包裹在包装中。 The wrapper should be psitioned at the bottom left corner of the window. 包装器应位于窗口的左下角。 When a user resizes their window i would want the text in div 2 to overflow top the top instead of the default of moving the text the next line ( downwards) I want to text to move to the previous line ( upwards) and essentially push the Hello in div 1 upwards. 当用户调整窗口大小时,我希望div 2中的文本从顶部溢出,而不是默认将文本移至下一行(向下),而我想将文本移至上一行(向上)并实质上推动您好在div 1以上。

Basically the reverse of having top div stacked to the top and having the content pushed down as the screen is resized. 基本上是将顶部div堆叠到顶部并在调整屏幕大小时将内容下推。

Image that the dashed line is the bottom of the window, thenI would want the behavior like so 虚线是窗口的底部的图像,那么我想要这样的行为

  Hello
  Content in this box
  should be pushed to
  the top as you reduce
  page size
  ---------------------

However currently the div follow the normal behavior of sending the overlowed text to the next line like so ( Behavior I dont want) 但是目前div遵循正常的行为,将低调的文本发送到下一行,就像这样(我不想要的行为)

   Hello
   Content in this box should
   ------------------------
   be pushed to the top as you
   reduce page size

Something like this? 像这样吗 https://jsfiddle.net/tuk50ooy/ https://jsfiddle.net/tuk50ooy/

 #wrapper{bottom:0;position:absolute;} @media only screen and (max-width : 480px) { #wrapper{position:relative;} } 
 <div id="wrapper"> <div id="div1"> <span> Hello</span> </div> <div id="div2"> <span> Content in this box should be pushed to the top as you reduce page size</span> </div> </div> 

If I understand correctly, this should be default behaviour in an absolute positioned wrapper. 如果我理解正确,这应该是绝对定位包装中的默认行为。 Either check the JSFiddle or the snippet in full screen: 全屏检查JSFiddle或代码段:

 #wrapper { position: absolute; bottom: 5px; left: 5px; width: 50%; background: orange; padding: 5px; } 
 <div id="wrapper"> <div id="div1"> <span> Hello</span> </div> <div id="div2"> <span> Content in this box should be pushed to the top as you reduce page size</span> </div> </div> 

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

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