Make the contents of a div behave like a fixed background

Buts

I am trying to create an effect similar to that of: background-attachment:fixed; However I want to apply this affect to all elements contained within a div not just the background.

When you scroll down the div will move up the screen but it's contents some of which will be hidden in the overflow will come into view.

<div class="parent"> <!--- will move on scroll. Overflow hidden. --->
    <div class="child"></div><!--- won't move on scroll --->
    <div class="child"></div><!--- won't move on scroll --->
</div>

Ideally this will be a HTML and CSS solution, but I can stretch to some jQuery or DOM calls with JavaScript. Bear in mind that I would like to use this effect multiple times on one page, so it will need to be relatively succinct.


Apologies if this question has already been asked but I found it difficult to describe so perhaps I am using incorrect keywords in my searches. Any suggestions on how to better phrase this question will be appreciated.

Sergio Lopes

Did you try to fix the position of a DIV:

<style type="text/css">

#mydiv{
position: fixed;
left: 10px;
top: 50px;
}

</style>

<div id="mydiv">
Some content here
</div>

It could be you needed.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Make div behave as image

From Dev

Fixed background image for a div

From Dev

div background with fixed width

From Dev

Fixed background image for a div

From Dev

How to unveil a div with fixed contents

From Dev

Make an image inside a div act like a background image cover

From Dev

Make an image inside a div act like a background image cover

From Dev

Make a fixed and responsive div

From Dev

Make a fixed and responsive div

From Dev

Make soft keyboard behave like IOS in Android

From Dev

Make an object behave like a module - Python 3

From Dev

Make eshell tab completion behave like Bash

From Dev

How to make UITextField behave like a UISearchBar in Swift?

From Dev

Make VIM cursor behave like Elvis

From Dev

Make asp:LinkButton behave like asp:button

From Dev

Android: make Recyclerview behave like LinearLayout

From Dev

Make a function behave like an instantiated EventEmitter

From Dev

Make multiple contenteditables behave like one document

From Dev

Is there a way to make a html list behave like this

From Dev

Make a shift key behave like an arrow key

From Dev

Make Image Button Behave Like a Toggle Button

From Dev

TableView - Attempting to make it behave like Excel

From Dev

zsh completion: make sshrc behave like ssh

From Dev

How to make sub main behave like form?

From Dev

Make a selector behave like another in jQuery

From Dev

How to make a horizontal div scroll bar float like a fixed CSS div

From Dev

fixed div, content fixed but background-image not

From Dev

fixed background of div not working in chrome

From Dev

CSS - Background Image With a fixed Div