As BoltClock said, there's no way to do this with just CSS. However, it is possible to do it if you're willing to use Javascript. Basically you want to style any overflowed element that has a scrollHeight greater than its clientHeight. Here's a simple example that runs a script when the page loads, and adds an "overflowed" class to the elements that have scrollbars:
<html><head><title>Overflow styling example</title>
<style type="text/css">
div.outerdiv
{
width: 100px;
height: 100px;
overflow-y: auto;
float: left;
margin: 20px;
border: 1px solid black;
}
div.outerdiv.overflowed
{
background-color: #9999FF
}
</style>
<script type="text/javascript">
function crossBrowserEventAttach(objectRef, eventName, functionRef)
{
try {
objectRef.addEventListener(eventName, functionRef, false);
}
catch(err) {
try {
objectRef.attachEvent("on" + eventName, functionRef);
}
catch(err2) {
// event attachment failed
}
}
}
function overflowCheck(element) {
if (element.scrollHeight > element.clientHeight && element.className.indexOf("overflowed") < 0) {
element.className = element.className + " overflowed";
}
else if (element.className.indexOf("overflowed") >= 0) {
element.className = element.className.replace(" overflowed", "");
}
}
function checkPage() {
var elements = document.getElementsByTagName("div");
for (var i = 0; i < elements.length; i++) {
if (elements[i].className.indexOf("outerdiv") >= 0) {
overflowCheck(elements[i]);
}
}
}
crossBrowserEventAttach(window, "load", checkPage);
</script>
</head>
<body>
<div class="outerdiv">
Line 1<br />Line 2
</div>
<div class="outerdiv">
Line 1<br />Line 2<br />Line 3<br />Line 4<br />Line 5<br />Line 6<br />Line 7<br />Line 8<br />Line 9<br />Line 10<br />Line 11<br />Line 12<br />
</div>
<div class="outerdiv">
Line 1<br />Line 2<br />Line 3<br />
</div>
<div class="outerdiv">
Line 1<br />Line 2<br />Line 3<br />Line 4<br />Line 5<br />Line 6<br />Line 7<br />Line 8<br />Line 9<br />Line 10<br />Line 11<br />Line 12<br />
</div>
</body>
</html>
If you run this in your browser, the divs with content tall enough to give them scrollbars should be blue, and the ones without scrollbars should be white:
http://i51.tinypic.com/2zf96de.png
Note that if you use this technique with a page that modifies the DOM or otherwise has content that changes after it loads, you'll need to write additional event handlers to re-check the elements after their contents have changed.