Click here to Skip to main content
11,703,940 members (68,207 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: CSS
Hi,

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.

Regards,
Sunny_K
Posted 17-Jun-12 20:39pm
Comments
Sandeep Mewara at 18-Jun-12 3:06am
   
What is inside the div?
Sunnykumar08 at 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 at 18-Jun-12 4:21am
   
Would CSS max-width and max-height properties help you?
Sunnykumar08 at 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 at 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 at 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
good
Please Sign up or sign in to vote.

Solution 1

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

only works when the element is set to display:block
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 550
1 Maciej Los 530
2 Sergey Alexandrovich Kryukov 381
3 Andy Lanng 294
4 CPallini 195
0 OriginalGriff 8,744
1 Sergey Alexandrovich Kryukov 7,747
2 CPallini 5,107
3 Maciej Los 4,716
4 Mika Wendelius 3,606


Advertise | Privacy | Mobile
Web01 | 2.8.150819.1 | Last Updated 19 Jun 2012
Copyright © CodeProject, 1999-2015
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