azlar azlar - 2 months ago 8
CSS Question

css absolute element hid by overflow: auto

When I hover the link, an

absolute pseudo element
will show.

I make the div
overflow-y: scroll
, those
pseudo element
outside view can't show, they were still using the position without
scroll
getting computed.

Chrome has that problem, Firefox works well.

Here are two images:






.blog .widget-panel {
height: 400px;
width: 200px;
margin: 20px;
position: fixed;
}

.blog .widget-panel > div {
overflow-x: hidden;
overflow-y: auto;
height: 100%;
}

.blog .widget-panel .tag-box .tag-block {
display: block;
line-height: 28px;
border-bottom: 1px dotted rgba(0,0,0,0.1);
padding: 7px;
color: #666;
background-color: #fff;
}

.blog .widget-panel .tag-box .tag-block:hover,
.blog .widget-panel .tag-box .tag-block.selected {
background-color: #38B7EA;
color: #fff;
}

.blog .widget-panel .tag-box.block .tag-block[data-title]:hover:after {
content: attr(data-title);
position: absolute;
z-index: 20;
white-space: nowrap;
background: rgba(85,85,85, 0.9);
padding: 4px 8px;
color: #fff;
font-size: 14px;
line-height: 18px;
margin-top: 2.8em;
}

.blog .widget-panel .tag-box .tag-block .count{
float: right;
}

<div class="blog">
<div class="panel panel-default widget-panel">
<div class="tag-box block">

<a class="tag-block" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
All
<span class="count">14</span>
</a>
<a class="tag-block tag-test" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
test
<span class="count">7</span>
</a>
<a class="tag-block" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
All
<span class="count">14</span>
</a>
<a class="tag-block tag-test" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
test
<span class="count">7</span>
</a>
<a class="tag-block" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
All
<span class="count">14</span>
</a>
<a class="tag-block tag-test" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
test
<span class="count">7</span>
</a>
<a class="tag-block" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
All
<span class="count">14</span>
</a>
<a class="tag-block tag-test" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
test
<span class="count">7</span>
</a>
<a class="tag-block" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
All
<span class="count">14</span>
</a>
<a class="tag-block tag-test" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
test
<span class="count">7</span>
</a>
<a class="tag-block" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
All
<span class="count">14</span>
</a>
<a class="tag-block tag-test" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
test
<span class="count">7</span>
</a> <a class="tag-block" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
All
<span class="count">14</span>
</a>
<a class="tag-block tag-test" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
test
<span class="count">7</span>
</a> <a class="tag-block" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
All
<span class="count">14</span>
</a>
<a class="tag-block tag-test" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
test
<span class="count">7</span>
</a> <a class="tag-block" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
All
<span class="count">14</span>
</a>
<a class="tag-block tag-test" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
test
<span class="count">7</span>
</a> <a class="tag-block" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
All
<span class="count">14</span>
</a>
<a class="tag-block tag-test" href="#" data-title="A few languages with well-developed systems of articles may distinguish additional subtypes. Within each type, languages may have various forms of each article">
test
<span class="count">7</span>
</a>

</div>
</div>
</div>




Answer

Working Fiddle: jsfiddle.net/TheBigDMo1/k2ahruyb/4

Use CSS tooltips : http://www.w3schools.com/css/css_tooltip.asp
     - If you use this option you need to get rid of the data-title attribute altogether

Here is your CSS:

    .blog .widget-panel {
    height: 200px;
    width: 200px;
    margin: 20px;
    position: fixed;
}

.blog .widget-panel .tag-box {
    overflow-x: hidden;
    overflow-y: auto;
    height: 100%;
}

.blog .widget-panel .tag-box.remove-over-flow {
    overflow-x: visible;
    overflow-y: visible;
}

.blog .widget-panel .tag-box .tag-block {
    display: block;
    line-height: 28px;
    border-bottom: 1px dotted rgba(0,0,0,0.1);
    padding: 7px;
    color: #777;
    background-color: #fff;

    position: relative;
}

.blog .widget-panel .tag-box .tag-block .tooltip-text {
    visibility: hidden;
    background-color: black;
    color: #fff;
    text-align: center;
    padding: 5px 0;
    margin-left: 10px;
    padding-left: 5px;
    border-radius: 6px;
    z-index: 1;

    white-space: nowrap;

    /* Position the tooltip text - see examples below! */
    position: fixed;
}

.blog .widget-panel .tag-box .tag-block .tooltip-text::after {
    content: " ";
    top: 50%;
    right: 100%;
    margin-top: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: transparent black transparent transparent;

    /* Position the tooltip text - see examples below! */
    position: absolute;
}


.blog .widget-panel .tag-box .tag-block:hover .tooltip-text,
.blog .widget-panel .tag-box .tag-block.selected .tooltip-text {  
    visibility: visible;
    /*background-color: #38B7EA;*/
    /*color: #fff;*/
}

Here is your jQuery:

$(".tag-block").on('click', function () {
    $(".tag-box").toggleClass("remove-over-flow");
});

$('.tooltip-text').click(function() {
    $(this).hide();
});

edited: added working Fiddle, added CSS