4

Here's a sample code:

#top {
  background: lightGreen;
}

#content {
  outline: 1px solid red;
}

#bottom {
  background: lightBlue;
}
<div id="top">Top</div>

<div id="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>

<div id="bottom">Bottom</div>

How can I pull up the content div 30% its height in the document flow? As you know, margin-top: -30% doesn't work since the size of the margin as a percentage is relative to the width of the containing block. Positioning and transforming don't seem to help either as they just visually shift the content of the element and its original space is reserved. Any other CSS approach to achieve the following effect?

enter image description here

Note: 30% is just an arbitrary number. It can be any percentage.

  • 2
    why cant you just change the element , put #content first , followed by #top in the html? – Daniel Paul Nov 29 '21 at 07:22
  • 2
    If you explain your entire scenario then better solutions can be found – the Hutt Nov 29 '21 at 11:00
  • Does it have to be a percentage? What is it you are trying to do? Just have the top bar behind the content and slightly below the content's top edge, by any CSS means necessary? What else is there on the page? Any containers we need to be aware of? – TylerH Nov 29 '21 at 14:29
  • 2
    @TylerH: "Does it have to be a percentage?" Yes. "Just have the top bar behind the content and slightly below the content's top edge" Not really: It can play from 0% to 100%. "What else is there on the page?" Nothing more, but feel free to add other wrappers or children if necessary. And yes: any CSS goes. –  Nov 29 '21 at 15:26
  • 2
    'pull up the content' what do you mean?? Please explain more – Jason Dec 01 '21 at 13:11
  • @Jason: The effect you see when using a negative `margin-top`. –  Dec 02 '21 at 05:20

8 Answers8

2

How can I pull up the content div 30% its height in the document flow?

One approach to achieve this effect involves three steps:

  1. Calculate the height of the content div using javascript
  2. Use the number calculated by javascript to populate a CSS Custom Property
  3. In your CSS stylesheet, apply the value of the Custom Property to margin-top

Yes, that means you will have to add two lines of javascript - but once you've added those lines, you'll not have to touch javascript again.

Instead, you'll be able to perform, tweak, update all the rest of your manipulations in CSS, using the CSS calc() function.


Working Example

const contentDiv = document.querySelector('#content');
contentDiv.style.setProperty('--contentHeight', (0 - contentDiv.offsetHeight + 'px'));
body {
  padding-top: 40px; /* <= Not necessary; just for breathing space */
}

#top {
  background: lightGreen;
}

#content {
  margin-top: calc(var(--contentHeight) / 100 * 30); /* 30% of #content height */
  outline: 1px solid red;
}

#bottom {
  background: lightBlue;
}
<div id="top">Top</div>

<div id="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>

<div id="bottom">Bottom</div>

Further Reading:

Rounin
  • 27,134
  • 9
  • 83
  • 108
  • 1
    Why does this add 40px of padding above the content? It doesn't seem necessary to achieve the overlapping effect as you've implemented it. – TylerH Nov 29 '21 at 14:32
  • 1
    @TylerH - It isn't necessary. I wanted to give the div in the code snippet some breathing space. – Rounin Nov 29 '21 at 20:31
1

Margin percentages are based on " logical width of containing block".

logical width A measurement in the inline dimension: refers to the physical width (horizontal dimension) in horizontal writing modes, and to the physical height (vertical dimension) in vertical writing modes. ref

So if we change containing block to vertical writing mode then margins will be based on height. And we can use margin-top: -30% based on height of the container.

Demo:

body {
  margin: 0;
  padding: 0;
  /*adding the top padding to able to see shifting parts*/
  padding-top: 100px;
  /* for better demo limiting to stackoverflow result width */
  width: 590px;
}

#top {
  background: lightGreen;
}

#wrapper {
  /* making it vertical mode */
  writing-mode: vertical-lr;
  width: 100%;
}

#content {
  border: 1px solid red;
  /* back to horizontal mode */
  writing-mode: horizontal-tb;
  float: left;

  /*  margin-top: -30%; */
  /* to see content movement live */
  animation: moveMe 4s steps(1, start) infinite alternate none;
}

#bottom {
  background: lightBlue;
  /* back to horizontal mode */
  writing-mode: horizontal-tb;
  width: 100%;
  float: left;
}


/* changing margin-top in steps*/


/* Note: we've used percentages here. You can do it manually. */

@keyframes moveMe {
  0% {
    margin-top: -0%;
  }
  10% {
    margin-top: -0%;
  }
  40% {
    margin-top: -30%;
  }
  70% {
    margin-top: -60%;
  }
  100% {
    margin-top: -100%;
  }
}
<div id="top">Top</div>
<div id="wrapper">
  <div id="content">
    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
    in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. lorem100

  </div>
  <div id="bottom">Bottom</div>
</div>

You can add more text to the #content div without modifying the CSS.


Practical use of this technique could be https://stackoverflow.com/a/70067583/15273968

the Hutt
  • 16,980
  • 2
  • 14
  • 44
  • 1
    Good catch `writing-mode`! But since you move `#bottom` into the same container with `#content` the 30% will be calculated based on the height of the container (equal the total height of content and bottom) – Duannx Nov 30 '21 at 08:36
  • @Duannx ahh! we need to subtract bottom height from 30% – the Hutt Nov 30 '21 at 08:38
  • Yeah. But how do we do it? Maybe the `#bottom` is dynamic content. – Duannx Nov 30 '21 at 09:12
  • could be, but nothing has been mentioned about heights in OP. It could be fixed height footer too, then subtract height straight away. If It's dynamic then may be a fixed height #bottom with scrollbar or we need to start thinking in terms of view height `vh`, because something has to have fixed height to keep solution CSS only. If Javascript was allowed then he wouldn't need the bounty. With this solution we can allow main content free to grow. – the Hutt Nov 30 '21 at 09:39
  • Creative approach, but the the wrapper `div`'s space is still there. Add an element under the wrapper and you'll see the gap. –  Nov 30 '21 at 12:01
  • @Mike in comments below OP you said there is nothing more on the page. Are there more components on the page? Are heights for #top, #content, #bottom fixed and and known before hand so that can be used in CSS directly? Is it ok if we assign them heights proportional to the view port? Are scroll bars ok if heights exceeds viewport? Is Javascript acceptable? Something has to have fixed height. – the Hutt Nov 30 '21 at 12:18
  • "_Are there more components on the page?_" Not for now, but they might be added to the top or bottom of your wrapper later. "_Are heights for #top, #content, #bottom fixed and and known before hand so that can be used in CSS directly?_" No fixed height. "_Is it ok if we assign them heights proportional to the view port?_" Using a fixed position? No. "_Are scroll bars ok if heights exceeds viewport?_" Yes. "_Is JavaScript acceptable?_" That's out of the question. –  Nov 30 '21 at 12:39
0

As I understand, the right question should be "pull up an element and all the elements below it". If that is true, there are 2 scenarios.

Scenarios 1: Your #top element's height is smaller than 30% of your #content element's height. In this situation, we have a pure CSS solution. But you need to adjust your HTML a bit.

  • Put your #top div into #content div
  • Set position: absolute and top: 30% to #top div
  • Set transform: translateY(-100%) for #top div. 100% value here will apply based on the height of #top so it will be placed in deserved position. It's simply math.

#top {
  background: lightGreen;
  position: absolute;
  top:30%;
  width: 100%;
  transform: translateY(-100%);
}

#content {
  position: relative;
  outline: 1px solid red;
}

span {
  position: relative;
  z-index: 1;
}

#bottom {
  background: lightBlue;
}
<div id="content">
<div id="top">Top</div>
<span>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</span>
</div>

<div id="bottom">Bottom</div>

Scenarios 2: Your #top element's height is bigger than 30% of your #content element's height. In this situation, I'm afraid that JS is the only way can help you. You can calculate the height of the element by JS and add a negative margin to it based on the height

document.addEventListener("DOMContentLoaded", ()=>{
  const content = document.getElementById('content')
  const height = content.getBoundingClientRect().height
  content.style.marginTop = `-${height*0.3}px`
});
#top {
  background: lightGreen;
}

#content {
  outline: 1px solid red;
}

#bottom {
  background: lightBlue;
}
<div id="top">
Top <br/>
Top <br/>
Top <br/>
Top <br/>
Top <br/>
Top <br/>
</div>

<div id="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>

<div id="bottom">Bottom</div>
Duannx
  • 7,501
  • 1
  • 26
  • 59
  • OP mentioned "It can play from 0% to 100%." In scenario 1, at initial state, when pull up is 0%, #top is out of the viewport i.e. all elements are not in view port, unlike your scenario 2. You need to add padding-top to the body. But if #top is dynamic content then you won't know how much padding is needed. Even if you remove transform #top will always remain behind #content. Also, if #top height > #content then you'll never see upper part of the #top. – the Hutt Nov 30 '21 at 10:15
  • FWIW, in another comment under an answer, OP also mentioned that JavaScript is out of the question. – TylerH Nov 30 '21 at 14:03
  • Yeah. I'm out of idea for this question. It's not worth the time we spent on it (except the bounty :)) ) because it will not have much value on real-life problems. – Duannx Dec 01 '21 at 04:22
0

Here is a less-than-elegant solution using position: relative on the body (or insert your own container div, if you like) and position: relative plus top on the content div to move it up a percentage.

When the parent is body, the percentage is necessarily of the body, which typically is the whole viewport. If you want to use bigger percentages and not have the content shoot off-screen, you could make body smaller, if nothing else is on the page, or use a wrapper div.

Now, I know you said:

Positioning and transforming don't seem to help either as they just visually shift the content of the element and its original space is preserved.

But per your comment that "any CSS goes", I've just applied the same CSS to both the #content and the #bottom divs to avoid the appearance of reserved space:

html, body {
    height: 100%; /* an absolute or relative value here, or an absolute value lower down, is required so that percentage value of the relevant elements has something to be a percent _of_ */
    margin: 0; /* just for demo's sake so there is no scrollbar */
}
#top {
    background: lightGreen;
}
#content {
    outline: 1px solid red;
    position: relative; /* required to allow positioned property of "top" to work */
    top: -1.7%; /* does the actual work of moving the element up */
}
#bottom {
    background: lightBlue;
    position: relative; /* required to allow positioned property of "top" to work */
    top: -1.7%; /* does the actual work of moving the element up */
}
<div id="top">Top</div>

<div id="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>

<div id="bottom">Bottom</div>
TylerH
  • 20,799
  • 66
  • 75
  • 101
  • Thanks for the answer, but it doesn't look right if I increase the `top`s value to, let's say, `-50%`: [Fiddle](https://jsfiddle.net/8Lqsb5jh/). –  Nov 29 '21 at 18:42
  • @Mike Yes, like I mentioned in the second paragraph, the percent is based on the `body` element, so in this case, that's the full viewport. If you set it to -50% it's going to move it up 50% of the viewport's height, or fully out of view in the case of the current content. If you want to work with bigger percentage numbers, you can add a wrapper div. – TylerH Nov 29 '21 at 18:59
  • @Mike To explicitly state it from another perspective, you simply *cannot* calculate a CSS value percentage based on the content that the percentage property value itself is applied to; that's just not how percentage values work in CSS; percentage property values are based on the nearest absolutely-sized version of that property (e.g. % width depends on `width: `) higher up the chain. – TylerH Nov 29 '21 at 21:04
0

The result that I am seeing in the question is when the content of the page is pulled up the header should stay behind. This will automatically be adjusted with the viewport when the content has a scrollable body.

Note that the attribute top in element Id #top can be changed to use percentages as well.

<style>
#top {
    background: lightGreen;
    top: 0px;
    position: sticky;
    z-index: 0;
}

#content {
    outline: 1px solid red;
    z-index: 1;
    background-color: white;
}

#bottom {
    background: lightBlue;
}
</style>


<div id="top">Top</div>

<div id="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
<div id="bottom">Bottom</div>
0

Preliminary idea

If it is permissible to duplicate content in two blocks (for example, if the page code is compiled by the CMS engine), then we can create a system of blocks.

The first instance of content will be hidden using the visibility property, but will set the 100% reference height we need. The second instance of the block will be visible and positioned absolutely relative to its invisible counterpart.

The content has risen to the desired percentage of height, and this percentage can be changed arbitrarily. The top property in percentages means the percentages of the height of the containing block.

But we got a gap between the raised block and the footer of the page:

#top {
  background: lightGreen;
}

#bottom {
  background: lightBlue;
}

.content {
  outline: 1px solid red;
}

.position-relative {
  position: relative;
}

.pull-up {
  position: absolute;
  top: -30%;
  left: 0;
  right: 0;
}

.visibility-hidden {
  visibility: hidden;
}
<div id="top">Top</div>

<div class="position-relative">
  <div class="content visibility-hidden">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>

  <div class="content pull-up">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
</div>

<div id="bottom">Bottom</div>

Final Solution Proposal

To get rid of the gap, we need to pull up all subsequent page content as well. To do this, we put it, along with the content duplicate, in the common intermediate wrapper pull-up.

It is this wrapper that we position absolutely and raise it 30% of the parent's height. Its parent is the position-relative block with the CSS property of the same name. And the parent's height is set by the first invisible instance of our content.

To make sure that the absolutely positioned box is fully visible in the browser, I enlarged the bottom box.

#top {
  background: lightGreen;
}

#bottom {
  background: lightBlue;
}

.content {
  outline: 1px solid red;
}

.position-relative {
  position: relative;
}

.pull-up {
  position: absolute;
  top: -30%;
  left: 0;
  right: 0;
}

.visibility-hidden {
  visibility: hidden;
}
<div id="top">Top</div>

<div class="position-relative">
  <div class="content visibility-hidden">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
    in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>

  <div class="pull-up">
    <div class="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
      dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>

    <div id="bottom">
      <p>Bottom 1</p>
      <p>Bottom 2</p>
      <p>Bottom 3</p>
      <p>Bottom 4</p>
      <p>Bottom 5</p>
      <p>Bottom 6</p>
      <p>Bottom 7</p>
      <p>Bottom 8</p>
      <p>Bottom 9</p>
    </div>
  </div>
</div>
Gleb Kemarsky
  • 10,160
  • 7
  • 43
  • 68
-1

If you know content height then you can use sibling combinator ~ to pull all following siblings up.

:root {
  --content-height: 100px;
}

body {
  padding-top: 100px;
  width: 590px;
}

#top {
  background: lightGreen;
}

#content {
  border: 1px solid red;
  height: var(--content-height);
}

#bottom {
  background: lightBlue;
}

#content,
#content~div {
  /*
  transform: translateY(calc(var(--content-height) * -0.3));
  */
  animation: moveMe 4s steps(1, start) infinite 1s alternate none;
}

@keyframes moveMe {
  0% {
    transform: translateY(0px);
  }
  10% {
    transform: translateY(0px);
  }
  40% {
    transform: translateY(calc(var(--content-height) * -0.3));
  }
  70% {
    transform: translateY(calc(var(--content-height) * -0.6));
  }
  100% {
    transform: translateY(calc(var(--content-height) * -1));
  }
}
<div id="top">Top</div>
<div id="content">
  Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
  in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
<div id="bottom">Bottom</div>

Using same strategy you can position all of them relative, absolute, or fixed and set top:30%, transform:translate(-100%).


Group: If you group #content and #bottom then you need to move only the group:

:root {
  --bottom-height: 1.2em;
}

body {
  padding-top: 110px;
  width: 590px;
}

#top {
  background: lightGreen;
}

#group {
  /*transform: translateY(-30%)*/
  animation: moveMe 4s ease-in-out infinite 1s alternate none;
}

#content {
  outline: 1px solid red;
}

#bottom {
  background: lightBlue;
}

@keyframes moveMe {
  0% {
    transform: translateY(0px);
  }
  100% {
    transform: translateY(calc(-100% + var(--bottom-height)));
  }
}
<div class=wrapper>
  <div id="top">Top</div>
  <div id="group">
    <div id="content">
      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
      in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    </div>
    <div id="bottom">Bottom</div>
  </div>
</div>
the Hutt
  • 16,980
  • 2
  • 14
  • 44
  • Why did you delete your other solution which grouped content into some container divs? I don't see a comment by OP explaining that that was wrong or anything. – TylerH Nov 29 '21 at 14:34
  • 1
    I realized later that translating the group will shift it by 30% of entire group's height, and not by 30% of #content height alone. In the group #bottom div height affects the shift. – the Hutt Nov 29 '21 at 14:51
-3

Hope it's work for you !!!

.wrapper { display: flex; flex-direction: column;}
        #top {
          height: 1em;
          background: lightGreen;
          order: 2;
        }

        #content {
          outline: 1px solid red;
          order: 1;
          margin-bottom: -15px;
          position: relative;
        }

        #bottom {
          height: 1em;
          background: lightBlue;
          order: 3;
        }
<div class="wrapper">
        <div id="top"></div>
        <div id="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
        <div id="bottom"></div>
    </div>