Brent Meeusen
Brent Meeusen

Reputation: 259

Scrolling in DIV?

I programmed a website where you can scroll in a DIV. But I actually want that if you scroll down, the title and the first paragraph in that div keeps their position, but the rest of the text underneath it come up.

I have the following in my HTML:

<html>
<head>
<link rel="stylesheet" type="text/css" href="UnCo.css">
<title>21Webb | Under Construction</title>
</head>

<body>
    <div class="updateSoMe blok alBeMe" style="overflow:scroll; height:100px;">
    <h1>Updates & social media</h1>
    <p>"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
    <p>"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</p>
</div>
</body>
</html>

And this in my CSS:

.updateSoMe {
display: inline-block;
float: right;
}

.updateSoMe h1 {
text-align: center;
}

.alBeMe {
width: 49%;
}

.alBeMe h1 {
background-color: #F6A22C;
margin: 0px;
border-radius: 8px;
border-bottom-right-radius: 0px;
border-bottom-left-radius: 0px;
}

EDIT: CODE NEW!! --> If you paste the HTML code in a document and place it in a folder, do the same with the CSS and place that one in the same folder and then open the HTML in IE or GC or FF or whatever you're using :)

Now, I want the h1 and the first <p> tag to stick at the top when you scroll down in the div, and the second <p> tag to be scrolled down.

Is this possible and if so, can you help me please?

Thank you!
Brent

Upvotes: 2

Views: 67

Answers (2)

Razia sultana
Razia sultana

Reputation: 2221

<div class="scroll">It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</div>


div.scroll {
background-color: #00FFFF;
width: 300px;
height: 200px;
overflow: scroll;
margin:10px;
}

Upvotes: 0

D.Soderberg
D.Soderberg

Reputation: 950

I don't know if this is what you really want because you didnt send your own code maybe I am wrong, but can't you have the title and the first paragraph outside of the scrollable div?

For exmaple in this jsfiddle you can scroll down the content but you have a header that is fixed above the scrollable div. Is this something you can use?

EDIT: Saw that you posted your code now.

Upvotes: 3

Related Questions