0

I have a div scrollable content and in it is a header that should overflow its parent. It seems that overflow: scroll adds overflow: hidden to the element.
If you could help me I would appreciate it. Thanks!

The HTML:

<div class="container">
    <div class="problem">This is hidden</div>
    <p>Content</p>
    <p>Content</p>
    <p>Content</p>
    <p>Content</p>
    <p>Content</p>
    <p>Content</p>
    <p>Content</p>
    <p>Content</p>
    <p>Content</p>
    <p>Content</p>
    <p>Content</p>
    <p>Content</p>
</div>

<div class="container container-2">
    <div class="problem">This is what i want, but scrollable.</div>
    <p>Content</p>
    <p>Content</p>
    <p>Content</p>
    <p>Content</p>
    <p>Content</p>
    <p>Content</p>
    <p>Content</p>
    <p>Content</p>
</div>

The CSS:

.container {
    width: 230px;
    height: 200px;
    background-color: #eeeeee;
    overflow-y: scroll;
    margin-top: 30px;
    margin-left: 30px;
    float: left;
}

.container-2 {
    overflow-y: visible;
}

.problem {
    width: 235px;
    height: 30px;
    background-color: #33CCFF;
    margin-left: -20px;
    margin-top: 15px;
}

1 Answer 1

1
.problem {
    width: 235px;
    height: 30px;
    background-color: #33CCFF;
    /*margin-left: -20px;*/  //this is the cause of problem comment this
    margin-top: 15px;
}

Demo Fiddle

Sign up to request clarification or add additional context in comments.

3 Comments

The idea is that I want the blue div to be a little bit outside of its parent like it is in the last one, but in the first one the overflow hides it.
@LucaBoieru like the second one is going in right, or you want it to the left
I want the blue div to be outside to the left (see the original code of the second example)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.