0
.demo{
     overflow:auto;
}

<div class="demo">
    <p>Some Text Here<P>
</div>

This piece of code displays the first part of the text like this, and you can then scroll down to show 5 and 6:

1  
2  
3  
4  

But I want it to display the last part of the text like this, which you can then scroll up to show 1 and 2:

3  
4  
5  
6  

How can I control it to display the end of the text?

2
  • 1
    So .demo will have a height and display a vertical scroll bar, and you want the initial position of the scroll bar to be at the bottom instead of the top of the content window. I think you need JavaScript/jQuery for this, CSS alone won't do it. Commented Apr 16, 2015 at 0:23
  • Some grammar changes to make it more understandable what you're trying to do. Also, example data is better put into code tags so it jumps out as "this is different to the explanation" Commented Apr 16, 2015 at 1:11

1 Answer 1

3

I believe this cant be done with just css since you want to scroll at the bottom of the div.

With your code, add in javascript to scroll to the bottom of the div

document.getElementById('scroll').scrollTop = 9999999;

I have created this fiddle for illustration, it has the same number example . Added height, width etc just illustration, you dont have to add any of those.

Click on Run snippet and let me know, if this is what you were looking for

document.getElementById('scroll').scrollTop = 9999999;
.demo{
     overflow-y:auto;
    overflow-x:hidden;
    width:10px;
    height:30px;
    padding:50px;
}
<div id="scroll" class="demo">
   1
    2
    3
    4
    5
    6
</div>

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.