Make a floated element a sticky

I have two columns, im trying to make the one on the left a sticky whn it reaches he top of the page, but I get
Can I not make a floated element a sticky?

urt, urt!,

Please validate the code that you posted and lettuce try again.:dolphin:

ok am using

why is it not working
shouldn’t the gray box be the sticky?

Your using flex so the sidebar is matching its height to the main content which has height 150vh.

Look back at the “How to…” link you posted. You will see a fixed height on the sticky element that is shorter than the scrolling content’s height.

#aside {
    width: 15%;
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    background-color: gray;
    height:50vh; /*added this for testing*/

To use flex and keep from setting a fixed height on your menu you can nest a new element in your aside.

That new element will no longer be a flex item and the menu content can determine it’s height. I used a <ul> in the following example.

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>San Diego: Configuration Management</title>

.wrapper {
  display: flex;
  justify-content: space-between;
.main {
  width: 85%;
  height: 150vh;
.aside {
  width: 15%;
.menu {
  position: -webkit-sticky;
  position: sticky;
  top: 0;


<div class="wrapper">
  <div class="aside">
    <ul class="menu">
      <li>menu item</li>
      <li>menu item</li>
      <li>menu item</li>
      <li>menu item</li>
  <div class="main">


align-self:flex-start on the side column would also work as long as you didn’t want full length backgrounds on the side column.

We had the same question a few days ago :slight_smile:


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.