Making Sticky notes with HTML5/CSS3

Source: Internet
Author: User

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
  1. <ul>
  2. <li><a href= "#">
  3. <h2>dudu:</h2>
  4. <p> I don't have a beauty post recently? I must give a headline, recommend!recommend!. </P>
  5. </a></li>
  6. <li><a href= "#">
  7. <H2> Uncle Tom:</h2>
  8. a member of < P >team went to Microsoft to do SDE3, and hire new member </P>
  9. </a></li>
  10. <li><a href= "#">
  11. <H2> Technology brother:</h2>
  12. <p>o2ds and I translated the book is the same, I must be faster than his turn, night overtime turn, fast! fast! fast! </P>
  13. </a></li>
  14. <li><a href= "#">
  15. <h2>artech:</h2>
  16. <p>WCF posts are very few, it seems I have to send a few posts to let everyone learn </P>
  17. </a></li>
  18. <li><a href= "#">
  19. <h2> Gizhgara:</h2>
  20. <p> Manage permissions and Workflow management to the extreme of my ability, a person can only do so few things </P>
  21. </a></li>
  22. <li><a href= "#">
  23. <H2> a martial arts expert:>
  24. <P> less than 25000 pieces of the interview will not go again, it Grandma </P>
  25. </a></li>
  26. </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
  1. *{
  2. margin:0;
  3. padding:0;
  4. }
  5. body{
  6. font-family:Arial,Sans-serif;
  7. font-size:100%;
  8. Margin:3em;
  9. Background:#666;
  10. Color:#fff;
  11. }
  12. h2,p{
  13. font-size:100%;
  14. Font-weight:normal;
  15. }
  16. ul,li{
  17. List-style:none;
  18. }
  19. ul{
  20. Overflow:hidden;
  21. Padding:3em;
  22. }
  23. UL Li a{
  24. Text-decoration:none;
  25. Color:#000;
  26. Background:#ffc;
  27. Display:block;
  28. Height:10em;
  29. Width:10em;
  30. Padding:1em;
  31. }
  32. UL li{
  33. Margin:1em;
  34. float: Left;
  35. }

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
    1. <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
    1. UL Li H2
    2. {
    3. font-size:140%;
    4. Font-weight:bold;
    5. padding-bottom:10px;
    6. }
    7. UL Li P
    8. {
    9. font-family: "Reenie Beanie", Arial,sans-serif, Microsoft ya Black;
    10. font-size:110%;
    11. }

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
    1. UL Li a
    2. {
    3. Text-decoration:none;
    4. Color: #000;
    5. Background: #ffc;
    6. Display:block;
    7. Height:10em;
    8. Width:10em;
    9. Padding:1em; /* Firefox */
    10. -moz-box-shadow:5px 5px 7px Rgba (33,33,33,1); /* Safari+chrome */
    11. -webkit-box-shadow:5px 5px 7px Rgba (33,33,33,.7); /* Opera */
    12. box-shadow:5px 5px 7px Rgba (33,33,33,.7);
    13. }

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
    1. UL Li a{
    2. -webkit-transform:rotate ( -6DEG);
    3. -o-transform:rotate ( -6DEG);
    4. -moz-transform:rotate ( -6DEG);
    5. }

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
  1. UL Li:nth-child (even) a{
  2. -o-transform:rotate (4DEG);
  3. -webkit-transform:rotate (4DEG);
  4. -moz-transform:rotate (4DEG);
  5. Position:relative;
  6. Top:5px;
  7. }
  8. UL Li:nth-child (3n) a{
  9. -o-transform:rotate ( -3DEG);
  10. -webkit-transform:rotate ( -3DEG);
  11. -moz-transform:rotate ( -3DEG);
  12. Position:relative;
  13. top:-5px;
  14. }
  15. UL Li:nth-child (5n) a{
  16. -o-transform:rotate (5DEG);
  17. -webkit-transform:rotate (5DEG);
  18. -moz-transform:rotate (5DEG);
  19. Position:relative;
  20. top:-10px;
  21. }

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
  1. UL Li A:hover,ul Li a:focus{
  2. -moz-box-shadow:10px 10px 7px rgba (0,0,0,.7);
  3. -webkit-box-shadow: 10px 10px 7px rgba (0,0,0,.7);
  4. Box-shadow:10px 10px 7px rgba (0,0,0,.7);
  5. -webkit-transform:scale (1.25);
  6. -moz-transform:scale (1.25);
  7. -o-transform:scale (1.25);
  8. Position:relative;
  9. Z-index:5;
  10. }

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
    1. -moz-transition:-moz-transform. 15s linear;
    2. -o-transition:-o-transform. 15s linear;
    3. -webkit-transition:-webkit-transform. 15s linear;

Then define the different colors in even and 3n:

View original CodeCSS Code copy content to clipboard
  1. UL Li:nth-child (even) a{
  2. -o-transform:rotate (4DEG);
  3. -webkit-transform:rotate (4DEG);
  4. -moz-transform:rotate (4DEG);
  5. Position:relative;
  6. Top:5px;
  7. Background:#cfc;
  8. }
  9. UL Li:nth-child (3n) a{
  10. -o-transform:rotate ( -3DEG);
  11. -webkit-transform:rotate ( -3DEG);
  12. -moz-transform:rotate ( -3DEG);
  13. Position:relative;
  14. top:-5px;
  15. Background:#ccf;
  16. }

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.