Click here to Skip to main content
12,548,647 members (47,181 online)
Rate this:
Please Sign up or sign in to vote.
See more: CSS

I want the DIV style to be changed when the contents within this DIV overflow... I have no Idea about doing this. Can anybody please help me how can I?

Any help is appreciated.

Posted 17-Jun-12 20:39pm
Sandeep Mewara 18-Jun-12 3:06am
What is inside the div?
Sunnykumar08 18-Jun-12 3:13am
there is grid inside the DIV. Number of records are dynamic hence "overflow" property of the DIV is set to "auto" so that scrollbars show up automatically. I want to set It's borders when overflow occurs.
krumia 18-Jun-12 4:21am
Would CSS max-width and max-height properties help you?
Sunnykumar08 18-Jun-12 4:51am
no they won't. I want something to occur when overflow happens, some action, change in style and this can not be done by setting max-width or max-height property. anyway, thanks for your time.
krumia 18-Jun-12 4:53am
I don't think what you say is possible. What exactly are you trying to do. Maybe there's a whole different way to do it.
Sunnykumar08 18-Jun-12 5:09am
Krumia, thanks again for replying, it's just like "div:hover" in which something happens when we drag the mouse pointer to the linked control. I also want something to be happened like- "link:overflow". Hope this explanation help you to understand the picture.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

var element = document.getElementById("div1");
if(element.scrollWidth > element.clientWidth)"solid"; //whatever change you want to make

only works when the element is set to display:block

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.161021.1 | Last Updated 19 Jun 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100