With HTML5/CSS3, you can create an HTML page with a sticky note effect in just 5 steps, as follows:
(Note: The text is purely fictional, funny purpose, if there is a similar, purely coincidental, thank you!)
Note: This effect can be seen in Safari, Chrome,firefox and Opera in the results, ie on the support of HTML5 is not complete, so do not see the effect.
First step: Create basic HTML and squares
First add the basic HTML structure and build the basic square with the following code:
xml/html Code copy content to clipboard
- <ul>
- <li><a href= "#">
- <h2>dudu:</h2>
- <p> I don't have a beauty post recently? I must give a headline, recommend!recommend!. </P>
- </a></li>
- <li><a href= "#">
- <H2> Uncle Tom:</h2>
- a member of < P >team went to Microsoft to do SDE3, and hire new member </P>
- </a></li>
- <li><a href= "#">
- <H2> Technology brother:</h2>
- <p>o2ds and I translated the book is the same, I must be faster than his turn, night overtime turn, fast! fast! fast! </P>
- </a></li>
- <li><a href= "#">
- <h2>artech:</h2>
- <p>WCF posts are very few, it seems I have to send a few posts to let everyone learn </P>
- </a></li>
- <li><a href= "#">
- <h2> Gizhgara:</h2>
- <p> Manage permissions and Workflow management to the extreme of my ability, a person can only do so few things </P>
- </a></li>
- <li><a href= "#">
- <H2> a martial arts expert:>
- <P> less than 25000 pieces of the interview will not go again, it Grandma </P>
- </a></li>
- </ul>
Each note adds an HREF connection, primarily to support keyboard access, and the CSS code is as follows:
View original Code
CSS Code copy content to clipboard
- *{
- margin:0;
- padding:0;
- }
- body{
- font-family:Arial,Sans-serif;
- font-size:100%;
- Margin:3em;
- Background:#666;
- Color:#fff;
- }
- h2,p{
- font-size:100%;
- Font-weight:normal;
- }
- ul,li{
- List-style:none;
- }
- ul{
- Overflow:hidden;
- Padding:3em;
- }
- UL Li a{
- Text-decoration:none;
- Color:#000;
- Background:#ffc;
- Display:block;
- Height:10em;
- Width:10em;
- Padding:1em;
- }
- UL li{
- Margin:1em;
- float: Left;
- }
The effect is as follows:
Step two: Shadow and handwritten cursive words
This step, we want to achieve a square shadow effect, and change the font to cursive (English only), because Google provides the font API support, so we can directly use, first add to the Google API call:
View original Codexml/html Code copy content to clipboard
- <link href= "Http://fonts.googleapis.com/css? " family=reenie+beanie:regular " rel=" stylesheet " type=" Text/css ">
Then set the reference to this font:
View original Codexml/html Code copy content to clipboard
- UL Li H2
- {
- font-size:140%;
- Font-weight:bold;
- padding-bottom:10px;
- }
- UL Li P
- {
- font-family: "Reenie Beanie", Arial,sans-serif, Microsoft ya Black;
- font-size:110%;
- }
With regard to shadows, because each browser is not fully supported, it needs to be processed separately, the code is as follows:
View original Codexml/html Code copy content to clipboard
- UL Li a
- {
- Text-decoration:none;
- Color: #000;
- Background: #ffc;
- Display:block;
- Height:10em;
- Width:10em;
- Padding:1em; /* Firefox */
- -moz-box-shadow:5px 5px 7px Rgba (33,33,33,1); /* Safari+chrome */
- -webkit-box-shadow:5px 5px 7px Rgba (33,33,33,.7); /* Opera */
- box-shadow:5px 5px 7px Rgba (33,33,33,.7);
- }
The effect is as follows:
Tilt the Square
Step three: Tilt the square
To make the square tilt, we need to add the following code to the Li->a:
View Original Generationxml/html Code copy content to clipboard
- UL Li a{
- -webkit-transform:rotate ( -6DEG);
- -o-transform:rotate ( -6DEG);
- -moz-transform:rotate ( -6DEG);
- }
But in order for the square to tilt randomly instead of all, we need to use the new CSS3 selector to let the square tilt 4 deg per 2, 3 deg per 3 tilt, 5 deg per 5:
View original CodeCSS Code copy content to clipboard
- UL Li:nth-child (even) a{
- -o-transform:rotate (4DEG);
- -webkit-transform:rotate (4DEG);
- -moz-transform:rotate (4DEG);
- Position:relative;
- Top:5px;
- }
- UL Li:nth-child (3n) a{
- -o-transform:rotate ( -3DEG);
- -webkit-transform:rotate ( -3DEG);
- -moz-transform:rotate ( -3DEG);
- Position:relative;
- top:-5px;
- }
- UL Li:nth-child (5n) a{
- -o-transform:rotate (5DEG);
- -webkit-transform:rotate (5DEG);
- -moz-transform:rotate (5DEG);
- Position:relative;
- top:-10px;
- }
The effect is as follows:
Fourth step: hover and focus when the square is indented
To achieve the zoom effect when hover and focus, we need to add the following code:
View original CodeCSS Code copy content to clipboard
- UL Li A:hover,ul Li a:focus{
- -moz-box-shadow:10px 10px 7px rgba (0,0,0,.7);
- -webkit-box-shadow: 10px 10px 7px rgba (0,0,0,.7);
- Box-shadow:10px 10px 7px rgba (0,0,0,.7);
- -webkit-transform:scale (1.25);
- -moz-transform:scale (1.25);
- -o-transform:scale (1.25);
- Position:relative;
- Z-index:5;
- }
The Z-index is set to 5 to allow the square to cover the other squares when zoomed in, and because the focus is also set, it also supports tab switch access.
The effect is as follows:
Smooth transitions and add colors
Fifth step: Smooth transitions and add colors
The fourth step of the effect, looks a bit stiff, we can add transition to achieve smooth animation effect, in addition to a single color, we can set a different color, first in the Ul->li->a to add transition:
View original CodeCSS Code copy content to clipboard
- -moz-transition:-moz-transform. 15s linear;
- -o-transition:-o-transform. 15s linear;
- -webkit-transition:-webkit-transform. 15s linear;
Then define the different colors in even and 3n:
View original CodeCSS Code copy content to clipboard
- UL Li:nth-child (even) a{
- -o-transform:rotate (4DEG);
- -webkit-transform:rotate (4DEG);
- -moz-transform:rotate (4DEG);
- Position:relative;
- Top:5px;
- Background:#cfc;
- }
- UL Li:nth-child (3n) a{
- -o-transform:rotate ( -3DEG);
- -webkit-transform:rotate ( -3DEG);
- -moz-transform:rotate ( -3DEG);
- Position:relative;
- top:-5px;
- Background:#ccf;
- }
In this way, we have finished our final effect:
Summarize
So far, we have used the basic features of HTML5 and CSS3 to make a good sticky note paste effect, HTML5/CSS3 is really very powerful, if you add some advanced features, such as the combination with JavaScript, can achieve a better effect, From when the resistance special brick home to everyone's HTML5 laboratory series article, can be seen.