javascript - Trying to get a header to stick to top of DIV and have content scroll beneath it -
i'm working on little css/html project , i'm running wall. hoping can here. here link ui i'm working on: imgur.com
what i'm trying have projects header sticky top of container div, , have items scroll beneath without overlapping header.
this css have container:
.projectcontainer { background-color: rgba(0, 0, 0, 0.15); width: 30%; height: 50%; border-radius: 2em !important; margin: 1em; overflow-y: auto; position: relative; }
and css have header.
.projectheader { position: absolute; padding-left: 35%; top: 0; height: 1.5em; }
edit: added bit of html i'm using:
<div class = "projectcontainer"> <div class="name projectheader">projects</div> <div class="projectthumbnail"> <a href="http://lunchline.herokuapp.com" target="_blank"> <i class="fa fa-cutlery fa-3x"></i> <p>lunchline</p> </a> </div> more project thumbnails here </div>
this doesn't work header scrolls else. tried using position: sticky on header, , problem content scrolled beneath header text instead of neatly ending @ bottom of header div. if can guide me in right direction i'd grateful.
also, sidenote: there way rid of gotdawful scrollbar , have thumb appear (and appear when i'm scrolling)?
thanks everyone.
edit: here js fiddle.
i tried stripping down container , stuff looks messy think shows i'm trying do.
i think biggest problem put overflow on main div, not on content div.
.container{ background:gray; color:white; width:400px; height:400px; display:flex; flex-direction:column; } .content{ flex:1; overflow:auto; }
<div class="container"> <h1 class="header">header</h1> <div class="content">content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br>content<br></div> </div>
Comments
Post a Comment