html - How to make text float over column when moused over? -
i want make text float on column edge when mouse-over it, ide does:
i can float on edge if change element positioning absolute
doesn't "take space".
also, wouldn't mind having border around floated bit either.
anyone have ideas how accomplish this?
i have had go @ , have come solution not require mark changes @ all, have done testing , seems work in chrome 26, safari 5.1.7, firefox 20, ie10, ie10 in ie9 mode , ie10 in ie8 mode, looks same in of these browsers , browser modes, starts break when using ie10 in ie7 mode.
it looks this:
basically i've done setting float:left
on li
, width:auto
on li:hover
, ensures text floats on column edge.
then add border, i'm rendering pseudo-element directly after li
, inherits width of preceding li
. i've set borders, margins, heights , line-heights position pseudo-element on top of preceding li
. i've set margin-left
150px
ensure shows behind li
's exceed width of column.
to add space @ right have changed white-space: no-wrap
white-space: pre
, preserve added white space inside li
(if added, not requirement, did add make little prettier).
here's jsfiddle.
here's html:
<div> <ul> <li>some long text </li> <li>some text doesn't fit column width </li> <li>yeah dude, sample text </li> <li>woot woot! double rainbows </li> </ul> </div>
and here's css:
li { white-space: pre; overflow-x: hidden; background-color: #f2f2f2; line-height: 21px; width: 150px; float: left; clear: both; } li:hover:after { content:''; height: 19px; margin: -21px 0px 0px 150px; border-width: 1px 1px 1px 0px; border-style: solid; display: block; } li:hover { width: auto; } div { width:155px; border-right: 3px solid; background-color: #f2f2f2; } ul:before, ul:after { content:' '; display: table; } ul { list-style: none; padding: 5px 0 5px 5px; margin: 0; } ul:after { clear: both; } body { margin: 0; padding: 0; }
update
i have included micro clearfix hack on div
, adjusts height based on contents instead of having fixed height.
update 2
the problem scrolling width of containing element changing when setting width:auto
on child elements, since scroll bar on right, keeps moving around. i've tried using wrapper div
, seems impossible float stuff on top of scroll bar, anywhere inside element creates scroll bar. way can scroll setting overflow:hidden
on ul
, using jquery scrollto plugin scroll , down inside ul
.
Comments
Post a Comment