简体   繁体   English

隐藏右侧的可变宽度元素

[英]Hide a variable-width element off to the right

I have the following layout: http://jsfiddle.net/yHPTv/2487/ 我有以下布局: http : //jsfiddle.net/yHPTv/2487/

What I need to do is hide the .hidden class to the right edge of the .block class and have it only appear (by sliding in) on hover to the current position you see it in the JSFiddle. 我需要做的是将.hidden类隐藏在.block类的右边缘,并使其仅在悬停时(通过滑入)显示到您在JSFiddle中看到的当前位置。

The issue is, the .hidden class is of variable-width, meaning that the content inside it ( ABCDEFGHIJKL ) can be completely different, sometimes shorter, sometimes longer. 问题是, .hidden类的宽度可变,这意味着其中的内容( ABCDEFGHIJKL )可以完全不同,有时更短,有时更长。

How would I solve this? 我该如何解决?

Edit: To clarify what I mean by hiding it to the right edge of the .block class, I mean like this , except it wouldn't be shown. 编辑:通过将其隐藏在.block类的右边缘来弄清楚我的意思,我的意思是这样 ,除非它不会显示。

HTML: HTML:

<div class="block">
    <div class="hidden">ABCDEFGHIJKL</div>
</div>

CSS: CSS:

.block {
    position: relative;
    width: 500px;
    height: 300px;
    overflow: hidden;
    background: lightgrey;
}

.block .hidden {
    background: red;
    padding: 3px 10px;
    position: absolute;
    bottom: 0;
    right: 0;
}

To solve my own question, I simply removed right: 0 from .block .hidden and put left: 100% . 为了解决我自己的问题,我只是从.block .hidden删除了right: 0 ,然后将left: 100%删除。

http://jsfiddle.net/yHPTv/2488 http://jsfiddle.net/yHPTv/2488

HTML: HTML:

<div class="block">
    <div class="hidden">ABCDEFGHIJKL</div>
</div>

CSS: CSS:

.block {
    position: relative;
    width: 500px;
    height: 300px;
    overflow: hidden;
    background: lightgrey;
}

.block .hidden {
    background: red;
    padding: 3px 10px;
    position: absolute;
    bottom: 0;
    left: 100%;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM