Categories
Uncategorized

How to add horizontal scroll or vertical scroll to a div

Using the overflow CSS property this can be achieved !

The overflow property specifies what happens if content overflows an element’s box.

If the content of the div is too tall, there will be a vertical scrollbar. If the content is too wide there will be a horizontal scrollbar.

Code

[sourcecode language=”html”]

<div style=”overflow:auto;width:300px;height:250px;”>

India, officially the Republic of India is a country in South Asia. It is the seventh-largest country by geographical area, the second-most populous country with over 1.2 billion people, and the most populous democracy in the world. Bounded by the Indian Ocean on the south, the Arabian Sea on the south-west, and the Bay of Bengal on the south-east, it shares land borders with Pakistan to the west; China, Nepal, and Bhutan to the north-east; and Burma and Bangladesh to the east. In the Indian Ocean, India is in the vicinity of Sri Lanka and the Maldives; in addition, India’s Andaman and Nicobar Islands share a maritime border with Thailand and Indonesia.

</div>

[/sourcecode]

Demo / Output

India, officially the Republic of India is a country in South Asia. It is the seventh-largest country by geographical area, the second-most populous country with over 1.2 billion people, and the most populous democracy in the world. Bounded by the Indian Ocean on the south, the Arabian Sea on the south-west, and the Bay of Bengal on the south-east, it shares land borders with Pakistan to the west; China, Nepal, and Bhutan to the north-east; and Burma and Bangladesh to the east. In the Indian Ocean, India is in the vicinity of Sri Lanka and the Maldives; in addition, India’s Andaman and Nicobar Islands share a maritime border with Thailand and Indonesia. In the Indian Ocean, India is in the vicinity of Sri Lanka and the Maldives; in addition, India’s Andaman and Nicobar Islands share a maritime border with Thailand and Indonesia.In the Indian Ocean, India is in the vicinity of Sri Lanka and the Maldives; in addition, India’s Andaman and Nicobar Islands share a maritime border with Thailand and Indonesia. In the Indian Ocean, India is in the vicinity of Sri Lanka and the Maldives; in addition, India’s Andaman and Nicobar Islands share a maritime border with Thailand and Indonesia.In the Indian Ocean, India is in the vicinity of Sri Lanka and the Maldives; in addition, India’s Andaman and Nicobar Islands share a maritime border with Thailand and Indonesia.

More — overflow-x and overflow-y

Follow these links for more information, overflow-x and overflow-y.