Please, oh Google-gods, rank this blog prominently, and let's save some poor, misguided souls who might be searching for some code on formating a query string in C# or merely grazing for urdu shayaris.... If just one person sees the light, then I've done my job! .... Yes, I am not above shamelessly begging the search engines for relevance .... it's called SEO, right?)
Tuesday, January 30, 2007
Day of nightmares ...
IE 6 is definately not standards complient...it takes a perfectly fine CSS and makes a mockery of it...
So, here is a little trick ..
Take a standard CSS...and put some custom tags in for IE6..
/*Standard Tags*/
padding-left:205px; /*left + margin of 10*/
margin-left:25px;
text-align:justify;
/*IE 6 Tags*/
_width:100%;
/*_border:thin solid green;*/
_margin-left:-100px;
_padding-left:0px;
So, when the page is parsed by standard browsers ..(FF, Opera, IE7 etc) they parse the right tags and then give you the pretty page..
IE6 on the other hand would read the tags with underscores and create an acceptable version of the page.....
IE6 and IE7 are very different browsers...No doubts abt it..
Thursday, January 11, 2007
DIVs and Background Images...
But then, that would be too eazy right ??
So, here is the catch - THE BACKGROUND IMAGES OF THE DIVs ARE NOT PRINTABLE.
Oh YES !! Exactly the nightmares I used to have....!!!!
Here is this heavenly perfect page I made and woopsie..the header and the footer of the page dont show up in the printouts...because by default, the browsers have the print feature disabled for the background images....
Not a very fun feeling, trust me...
So how to fix the problem ....I am still trying to work out a perfect solution but here are some of my attempts...
- Using the print style sheet -
@media print {
#title { letter-spacing:-1000px; }
#title:before { content: url(banner.jpg); }
}
- Using the DIV layering in the page
<div id="Body" style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px;
PADDING-BOTTOM: 0px; PADDING-TOP: 0px; HEIGHT: 800px" align="center"><p></p><p><img
height="100%" src="images1/background_image.jpg" width="1014"
border="0" /></p><p><div id="LeftNevigation"
align="left">Menu goes here</div><p></p><p><div
id="TopBanner" align="left">Banner goes here</div><p></p><p><div
id="CenterBody" align="left">Main Text Goes Here</div><p></p><p></p></div><p></p><p></p>
- Using the Line-Style Hack
I found another, non-HTML based solution (example) though, and list-style-image is the keyword. I explain.Instead of including our banner graphic via the background-image hook, we use CSS' "lists" functionality instead.Suppose you want the browser to print an image in the place of an h1 with id="title", then the following piece of print CSS does the trick:
#ti\tle {
/* 6. */display: list-item; /*
1. */list-style-image: url(banner.jpg);
/* 2. */list-style-position: inside;
/* 3. */letter-spacing: -1000em;
/* 4. */font-size: 1pt;
/* 5. */color: #fff;
/* 5. */}
Some annotations:
We give our h1 the characteristics of a list-item.
We pretend our banner image is a list-style-image.
Firefox wants you to put the image inside.
We make the text disappear into a black hole by means of Malarkey's Image Replacement (MIR).
As MIR doesn't work in Opera, we set the font-size to 1pt and make the text white. This works fine with Opera's default print settings. Other image replacement techniques rely on moving or hiding mechanisms, all of which would also hide our image. Hence small, white text.
As list-style-image is not supported in IE5 and IE5.5, we exclude these browsers with a simple escaping hack.