CSS Universe - Tips, Hacks
Monday, July 19, 2010
Design iPhone, Android, Blackberry and iPad web page interfaces using CSS media queries
< !DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd" >
2) Include meta tag < meta name="viewport" content="initial-scale=1.0" >
3) than u need media queries for portrait version and landscape version against the main classes which sets your main width.
these are called media queries.
For instance, Referring to my code I added following code in bottom area of my CSS
@media only screen and (max-width: 999px) {
/* rules that only apply for canvases narrower than 1000px */
}
@media only screen and (device-width: 768px) and (orientation: landscape) {
/* rules for iPad in landscape orientation */
}
@media only screen and (min-device-width: 320px) and (max-device-width: 480px) {
/* iPhone, Android, Blackberry rules here */
}
Enjoy HTML and CSS powers for layout presentation
Monday, June 22, 2009
Thursday, June 11, 2009
blockquotes CSS
Source Code is:
<head>
<style>
blockquote{background:transparent url(quoleft.gif) left top no-repeat;}
blockquote .blockDiv{padding:0 48px;background:transparent url(quoright.gif) right bottom no-repeat;}
.blockDiv{width:300px;font:11px/1.1em Arial, Helvetica, sans-serif;color:#777;text-align:justify;}
</style>
</head>
<body>>
<blockquote cite="http://www.w3.org/TR/REC-html40/struct/tables.html#h-11.1">
<div class="blockDiv">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
</blockquote>
</body>
Download the blockquote source code from here
There’s a simple trick at work here. CSS backgrounds are extremely powerful but in CSS2 only one background can be applied to any single element. The blockquote effect requires two background images, one for the quote mark on the left hand side and one for the one on the right. The additional nested <div> </div> allows us to do this, by applying one background image to the <blockquote></blockquote> and one to the <div> </div>.
The padding is applied to the <div> </div> rather than the <blockquote></blockquote> because the <div> </div> needs to stretch the entire width of the <blockquote></blockquote> in order for the background image to appear in the right place. The images are 38 pixels wide, so a padding is applied to the left and right hand sides of the <div> </div> to allow space for the images and give an extra 10 pixels of whitespace.
You can see the technique being used by downloading the free source code from here.
Thursday, May 21, 2009
CSS Property: white-space
White Space (CSS Property) - white-space: { normal | nowrap | pre | pre-line | pre-wrap | inherit };
Description
This property controls the handling of whitespace inside an element. Whitespace is a collective name for one or more occurrences of the characters space, tab, line feed, carriage return, and form feed. Typically, within an HTML element, user agents will collapse a sequence of whitespace characters into a single space character.
Note that this property only handles whitespace characters; a common beginner’s mistake is to try to use it to prevent floated elements from dropping down if there isn’t enough room on aline.
Example
This style rule makes elements that belong to the "poetry"
class retain and render all
whitespace in the document markup:
<code class="css">.poetry {
white-space: pre;
}</code>
Value
normal
- A value of
normal
dictates that sequences
of whitespace will collapse into a single space character. Line
breaks will occur wherever necessary to fill line boxes. nowrap
- Specifying
nowrap
ensures that sequences of
whitespace will collapse into a single space character, but line
breaks will be suppressed. pre
- Specifying
pre
ensures that sequences of
whitespace won’t collapse. Lines are only broken at new lines in the
markup (or at occurrences of"\a"
in generated
content). pre-line
- This value will cause sequences of whitespace to collapse into a
single space character. Line breaks will occur wherever necessary to
fill line boxes, and at new lines in the markup (or at occurrences
of"\a"
in generated content). In other words,
it’s likenormal
except that it’ll honor
explicit line breaks. pre-wrap
- Specify
pre-wrap
to ensure that sequences
of whitespace won’t collapse. Line breaks will occur wherever
necessary to fill line boxes, and at new lines in the markup (or at
occurrences of"\a"
in generated content). In
other words, it’s likepre
except that it’ll
wrap the text at the end of line boxes.
Compatibility
Internet Explorer: 5.5,6.0.7.0 (Partial)
Firefox 1.0,2.0,3.0 (Partial)
Safari 1.3,2.0,3.0 (Full)
Opera 9.2 (Partial) ,9.5 (Full)
Internet Explorer for Windows versions up to and including 7 don’t support the values
pre-line
or pre-wrap
. The values normal
and pre
behave like pre-wrap
on textarea
elements. The value nowrap
behaves like pre-line
on textarea
elements.
Internet Explorer for Windows versions up to and including 7 don’t support the value inherit
.
Firefox versions up to and including 2 don’t support the values pre-line
and pre-wrap
(although -moz-pre-wrap
is similar to the latter). The values normal
, nowrap
, and pre
behave like pre-wrap
on textarea
elements.
Opera 9.2 and prior versions don’t support the value pre-line
. The values normal
and pre
behave like pre-wrap
on textarea
elements. The value nowrap
behaves like pre-line
on textarea
elements.