html - Creating Dynamically Sized DIV Boxes with Static Headers -
i'm working on type of dashboard contains div's of various sizes. height , width percentage based , content of each div box dynamic. need create nice headers describe contents of box.
the header inside of box. causes lots of problems when overflow involved , makes spacing inner content annoying.
is there easier way sized headers inside of div or easier put them on top of boxes little hats.
this extremely close want header scrolls content! that's terrible.

this want, widget contraption describes it's own contents.
here's fiddle getting quite close
http://jsfiddle.net/exrxr/1019/
but position absolute overrides many things...
i put demo prior question being edited include link demo, first iteration, though after looking @ linked demo seems mark-up close:
<div class="dashwrap"> <h2>header</h2> <div class="dashcontent"> <p><!-- content --></p> </div> </div> the following css seems require:
.dashwrap { width: 50%; margin: 0 auto 1em auto; } .dashwrap h2 { background-color: #ffa; border: 2px solid #000; border-radius: 0.5em 0.5em 0 0; text-indent: 0.5em; } .dashwrap .dashcontent { max-height: 5em; overflow-x: hidden; overflow-y: auto; border: 2px solid #000; border-top-color: transparent; } edited following question op (in comments):
...i have no clue why works. if kind give me brief explanation why header stays in place miraculously extremely helpful.
the reason h2 stays 'in place' is, simply, because i've not moved it, or changed default display behaviour (an h2 defaults display: block); means remains in place within document's flow.
its sibling, .dashcontent, element able scroll because has 2 rules, first max-height prevents element growing vertically accommodate descendant element(s) , second overflow-y (which in browsers requires overflow-x set, hence above), allows contents of .dashcontent scroll.
Comments
Post a Comment