Modify the CSS Clip Property in a DIV

How can I change the values of the Cascading Style Sheets (CSS) clip property after the DIV is created?


For the current releases of Navigator and IE (IE 4.x/5.x and Navigator 4.x), altering the CSS clip property of a DIV block once the page is rendered will require handling some special cross-browser differences. First of all, the DIV block will need to be absolutely positioned for the dynamic clipping to work with both Navigator and IE. In addition, you’ll most likely want to provide a preliminary clipping area, though this isn’t required:


To perform the clipping, you will need to check for the type of browser before modifying the CSS clipping values. In this code, I use the object model to test for browser type primarily because of the brevity of the code for this approach; you will want to use your own favorite approach:

   if (document.all)"rect(0 400 400 0)";   else if (document.layers) {      document.temp.clip.right=400;      document.temp.clip.bottom=400;      }

The “document.all” condition succeeds for IE 4.x and IE 5.x and as the clipping value is modified by changing the entire clipping rectangle at once.

The second browser check, testing for “document.layers”, will succeed for Navigator 4.x and the code for this browser sets the right and bottom sides of the clipping rectangle individually.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


The Latest

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS

homes in the real estate industry

Exploring the Latest Tech Trends Impacting the Real Estate Industry

The real estate industry is changing thanks to the newest technological advancements. These new developments — from blockchain and AI to virtual reality and 3D printing — are poised to change how we buy and sell homes. Real estate brokers, buyers, sellers, wholesale real estate professionals, fix and flippers, and beyond may