Search

Change Language

Showing posts with label HTML AND CSS. Show all posts
Showing posts with label HTML AND CSS. Show all posts

Sunday, March 13, 2011

CSS transforms

Rotation 
<style type="text/css">
.rotation {
    -moz-transform: rotate(-20deg);
    background-color:#000;
    width:500px;
    height:500px;
   -webkit-transform: rotate(-20deg);
   -o-transform: rotate(-20deg);
   margin:100px;
}
.skew {
    -moz-transform: skewx(10deg) translatex(150px);
    -moz-transform-origin: bottom left;
    -webkit-transform: skewx(10deg) translatex(150px);
    -webkit-transform-origin: bottom left;
    -o-transform: skewx(10deg) translatex(150px);
    -o-transform-origin: bottom left;
      margin:100px;
}
</style>

<div class="rotation">
  <iframe src="http://www.genioplus.blogspot.com/" width="500" height="500"></iframe>
</div>

<div class="skew">
  <iframe src="http://genioplus.blogspot.com/" width="400" height="200"></iframe>
</div>

Example

Thursday, March 10, 2011

CSS Text Shadow

Regular text shadow:

p { text-shadow: 1px 1px 1px #000; } 

Multiple shadows:

p { text-shadow: 1px 1px 1px #000, 3px 3px 5px blue; }


The first two values specify the length of the shadow offset. The first value specifies the horizontal distance and the second specifies the vertical distance of the shadow. The third value specifies the blur radius and the last value describes the color of the shadow:
1. value = The X-coordinate
2. value = The Y-coordinate
3. value = The blur radius
4. value = The color of the shadow
Using positive numbers as the first two values ends up with placing the shadow to the right of the text horizontally (first value) and placing the shadow below the text vertically (second value).
The third value, the blur radius, is an optional value which can be specified but don’t have to. It’s the amount of pixels the text is stretched which causes a blur effect. If you don’t use the third value it is treated as if you specified a blur radius of zero.
Also, remember you can use RGBA values for the color, for example, a 40% transparency of white:

p { text-shadow: 0px 2px 2px rgba(255, 255, 255, 0.4); }

Examples


 p    
    { 
    text-shadow: 1px 1px 10px #000; 
    font-size:100px;
    color:#fff;
    }


 h1   
    {
    text-shadow: 1px 1px 1px yellow, 3px 3px 1px #000;
    font-size:100px;
    color:#fff;
    }


 h3 
    {
    text-shadow: 0.2em 0.5em 0.1em #600,
    -0.3em 0.1em 0.1em #060,
    0.4em -0.3em 0.1em #006;
    font-size:100px;
    }


h4 {
    text-shadow: -1px 0 black, 0 1px black,
     1px 0 black, 0 -1px black;
     font-size:100px;
     color:#fff;
    } 


/*This one is Internet Exlorer */
h2 
    {
    height: 5em;
    font-size:100px;
    color:#009900;
    filter: Shadow(Color=#666666,Direction=125, Strength=10);
}

Wednesday, March 9, 2011

Hiding Content for Accessibility

For years now, we've used a number of techniques for hiding content offscreen for accessibility purposes. We do this because the content is still accessible to screenreaders while being removed from the interface for sighted users.
An article over at Adaptive Themes reviews a number of techniques for hiding content that were considered for inclusion on a Drupal 7 project (but certainly applicable to any project).
Here is a summary of those techniques and the pitfalls of each technique:
Text Indent

.element-invisible {
  text-indent: -9999em;
  outline: 0;
}
Unfortunately, this technique doesn't work with RTL (Right-to-Left) languages.

Position Absolute and Collapsed

.element-invisible {
  height: 0;
  overflow: hidden;
  position: absolute;
}

In this case, Apple's Voice Over will not read content within an element that has 
zero height.

Position Absolute and Offscreen

.element-invisible {
  position: absolute;
  top: -999999em;
  left: auto;
  width: 1px;
  height: 1px;
  overflow:hidden;
}

In this case, if you have focusable content within the positioned
element, the page will scroll to that element, thus creating an
unsettling jump for sighted users.

Clip Method

.element-invisible {
  position: absolute !important;
  clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
  clip: rect(1px, 1px, 1px, 1px);
}

 The article ends with this final technique and is the solution they ended up using on their project.

With the work I've been doing at Yahoo!, we had been using the Position Absolute and Offscreen method. But sometimes we wanted to set focus to offscreen content. We had switched our technique to the Clip Method but uncovered differing behaviour between browsers.
Everything works great in Internet Explorer and Firefox. However, in Webkit (Chrome and Safari) and Opera, there's an interesting behavior when the element is at the edge of the screen. If the element, when unclipped, is large enough to force a horizontal scrollbar, will force a scrollbar even when clipped.
This seems to go against the CSS 2.1 guidelines that say:
Content that has been clipped does not cause overflow.
However, by forcing a scrollbar in Webkit and Opera, it does, in fact, seem to cause overflow. So how did we get around this?

Positioned, Clipped, and (almost) Collapsed

We combine a few techniques into one:
.element-invisible {
  position: absolute !important;
  height: 1px; width: 1px; 
  overflow: hidden;
  clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
  clip: rect(1px, 1px, 1px, 1px);
}
Using absolute positioning, we take the element out of flow so as not to affect the layout of anything around it. With a height of 1px, the element should still be visible for Voice Over to read the content. The clipping removes any visible trace of the element from the page.
Any focusable elements inside are still focusable, so depending on placement within the overall layout, some considered placement may still be of concern. Although, I might question why you are focusing on an element that was so far removed from the overall flow of the document.
We've only begun using and testing this technique, so even this may not be perfect. Any feedback and suggestions are quite welcome.

Tuesday, March 8, 2011

Pure CSS Gradients

CSS Gradients
One of the many cool CSS additions to come out of Webkit is the ability to specify gradients. Whereever you would normally specify an image using a url() syntax, you can specify -webkit-gradient instead. Probably the most likely scenario will be for background images but you could use it for border-image or list-style-image, too.
background-image: -webkit-gradient(linear, 0 top, 0 bottom, from(#496178), to(#2E4960));
The syntax takes a gradient type as the first parameter: linear or radial. The next two values indicate the start and stop points of the gradient. Each parameter after that is a color-stop(x, y) function where x is a percentage or a value between 0 and 1 and y is the colour value. from and to are shortcuts for color-stop(0, y) and color-stop(1, y) respectively. This implementation mirrors the functionality within the canvas specification.
CSS gradients have made their way into the W3C as a draft spec, although the syntax is different from how Webkit has implemented it. Firefox 3.6 has just been released and now includes CSS gradients using this newer syntax which separates the two types of gradients into their own syntax: -moz-linear-gradient and -moz-radial-gradient.
background-image: -moz-linear-gradient(90deg, #496178, #2E4960);
The first parameter is the position or angle. There are a number of ways
that the shorthand can be calculated and degrees are likely the easiest
to use. If you're doing a gradient from top to bottom, the angle can be
ignored altogether and the colour stops are all that need to be
specified.
 background-image: -moz-linear-gradient(#496178, #2E4960);
There's no need to specify the color-stop, from or to functions like with the webkit gradients. You can specify multiple colour stops and it'll create a gradient between each one. If you wish to adjust the position of where the gradient transitions, you can specify it as a second value with the color stop.
background-image: -moz-linear-gradient(#496178, #323232 20%, #2E4960);
You can also use values, too, if you wanted to create semi-opaque gradients.

Saturday, March 5, 2011

Text Rotation with CSS



CSS
<style type="text/css">
body
    {
    margin:0px;
    padding:0px;
    }
#main
    {
    float:left;
    width:105px;
    margin:10px;
    height:88px;
    mos-radius:10px;
    -moz-border-radius-topright:10px;
    -moz-border-radius-bottomleft:10px;
    border-radius: 15px;
    background-color:#66CC00;
    font-family:Verdana, Arial, Helvetica, sans-serif;
  
    }
#main1
    {
    float:left;
    width:105px;
    margin:10px;
    height:88px;
    mos-radius:10px;
    -moz-border-radius-topleft:10px;
    -moz-border-radius-bottomright:10px;
    border-radius: 15px;
    background-color:#00FFFF;
    font-family:Verdana, Arial, Helvetica, sans-serif;
  
    }
.date
    {
    font-size:50px;
    padding:0px;
    margin:0px;
    width:76px;
    float:left;
    text-align:center;
    }
.month
    {
    font-size:18px;
    text-align:center;
  
    }
.year
    {
    -webkit-transform: rotate(-90deg);
    -moz-transform: rotate(-90deg);
    float:left;
    width:23px;
    top:32px;
    left:0px;
    font-size:17px;
    text-align:center;
    position:relative;
    }
</style>

/*Code For Internet Explorer*/

<!--[if IE]>
    <style>
        .year {
            filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
            top:9px;       
        }
      
    </style>
    <![endif]-->


HTML

<div id="main">
   <span class="date">22</span>
   <span class="year">1990</span>
   <div class="month">December</div>
</div>

Tuesday, March 1, 2011

Font Embedding in HTML (compatible for all Browsers including IE6)

Font Formats
Generally speaking, these days, a font on our system is going to be one of two formats: TrueType (with a .ttf file extension) or OpenType (with a .otf file extension). While it would be nice to be able to just throw a font like this on the web and link it up, we're hit with two major limitations.
  1. Licensing, and
  2. Browser Support 

Browser Support

Which leads me into the other major issue, browser support. Font embedding with a TrueType or OpenType font only works as of Firefox 3.5, Safari 3.1, and Opera 10. (You can enable it in your copy of Chrome 2 by using a command line switch.)
Okay, that's decent already but we can do better. We can get Internet Explorer 4+, Chrome 0.3+, Opera 9+ and even a little mobile Safari action.

internet explorer only supports .eot  type

You can convert  .TTF  font to EOT Font  click here
You can convert  .OTF  font to TTF Font  click here

   script                                                                                                                                                         
<style type="text/css">
@font-face {
     font-family: "YourFont";
     src: url(font.eot);                    /* IE */
     src: local("YourFont"), url(font.ttf) format("truetype");  /* non-IE */
}
.test
    {
    font-family:YourFont;
    font-size:50px;
    }
</style>


Rounded Corners in Webkit (Pure CSS)

Much like Mozilla Firefox, Webkit allows developers to create pure CSS rounded corners in all browsers that use the Webkit engine, including Apple's Safari and Google's Chrome. Check out how easy implementing rounded corners can be!

 .sample {
  -webkit-border-radius:10px; /* all corners */
  -webkit-border-top-left-radius:15px; /* top left corner */
  -webkit-border-top-right-radius:50px; /* top right corner */
  -webkit-border-bottom-left-radius:15px; /* bottom left corner */
  -webkit-border-bottom-right-radius:50px; /* bottom right corner */
  border:1px solid #fc0; /* border color, per usual */
}