Use CSS3 to create an optional text, and css3 to create an optional text

Source: Internet
Author: User
Tags unsupported

Use CSS3 to create an optional text, and css3 to create an optional text

The following example shows how to use CSS to create optional texts in HTML5.

 

 

Html code
  1. <! Doctype html>
  2. <Html>
  3. <Head>
  4. <Title> Creating non-selectable text using CSS </title>
  5. <Style type = "text/css">
  6. Div {
  7. Margin-bottom: 20px;
  8. Padding: 10px;
  9. Background: rgba (10%, 10%, 10%, 0.3 );
  10. -Moz-border-radius: 15px;
  11. Border-radius: 15px;
  12. }
  13. Div # d2 {
  14. -Moz-user-select: none;
  15. -Khtml-user-select: none;
  16. User-select: none;
  17. Font-style: italic;
  18. }
  19. </Style>
  20. </Head>
  21. <Body>
  22. <Div id = "d1"> [selectable] Lorem ipsum dolor sit amet, consectetur adipiscing elit. curabitur ornare, urna placerat condimentum vehicula, magna est suscipit leo, auctor laoreet erat massa eget tellus. etiam pharetra, orci eu gravida tempus, enim est venenatis diam, id facilisis justo ante ut arcu. sed nibh eros, porta ac, fermentum ut ante. etiam pulvinar consectetur urna sit amet fermentum. aliquam quis pellentesque tortor. in ut lobortis enim. pellentesque luctus orci nec massa lacinia consectetur. etiam cursus, leo et pellentesque tempus, diam elit interdum ipsum, sed pulvinar nibh justo vel urna. phasellus ligula elit, sodales eget aliquet, ullamcorper ut lorem. praesent eget quam id ligula iaculis tincidunt eu et nulla. ut dui, dictum sed lobortis eu, porta nec urna. in adipiscing, massa sed scelerisque elementum, tortor massa cursus velit, ut tincidunt mi lacus id magna. morbi vestibulum venenatis massa sit amet convallis. aliquam erat volutpat. </div>
  23. <Div id = "d2"> [non selectable] Nam a lacus ante, a tincidunt dolor. sed felis dolor, ullamcorper vitae luctus at, iaculis eu dui. mauris ullamcorper nisl id tortor elementum mattis. aenean ut ligula ac ipsum pharetra dapibus. praesent convallis tincidunt ligula sit amet adipiscing. morbi massa mauris, mollis ornare mollis ut, imperdiet nec nibh. praesent sollicitudin tellus at nisl sodales lobortis euismod purus laoreet. vivamus nec urna vel nibh volutpat rhoncuquis eget justo. donec mi lacus, dapibus nec tristique eu, fringilla id mi. maecenas vitae odio a tortor cursus fermentum eu eget eros. vestibulum sit amet metus purus. integer vestibulum sem nec justo facilisis tempor non sit amet justo. lorem ipsum dolor sit amet, consectetur adipiscing elit. cras eget mattis metus. </div>
  24. <Div id = "d3"> [selectable] Proin lacinia sem fringilla est lacinia facilisis. praesent turpis massa, bibendum eu ultrices ut, viverra vitae quam. morbi a lorem mi, eget congue arcu. sed dapibus molestie neque, eget tempus nibh viverra. praesent sit amet vestibulum ipsum. donec in lectus ac urna accumsan feugiat. sed at nunc felis. vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Duis nec ipsum justo. nullam laoreet enim vel quam tincidunt imperdiet. maecenas sollicitudin nulla a metus ornare tempus. nullam rhoncus fermentum lorem id pellentesque. </div>
  25. </Body>
  26. </Html>

 

Download source code:

Creating-non-selectable-text-using-css.zip


What Should CSS3 do for browsers that are not applicable?

Currently, mainstream browsers support CSS3 in sequence: Chrome, safari, firefox, opera & IE9, firefox, and even CSS3 selectors are not all supported, while others support it. Apart from Chrome & safari, others have limited support for reflection, flip, and other styles. opera does not even support gradient and transform animations of background colors ). IE6 \ 7 \ 8 should not be too extravagant, even if part of IE8 that supports CSS3 is less than 1/10.

CSS3 is equivalent to a set of style sheet definitions written casually on unsupported browsers: div {haha: huhu;}, which does not affect the page style.

There is nothing to do if it is not supported. For corner, reflection, tilt (rotation), and other definitions in CSS3, it is usually replaced by a background image in an unsupported browser. Animation and other effects can only be implemented using javascript.

How to Use CSS3 to create 3D effects and text to implement style Solutions

Copy the Code as follows :. example-class {text-shadow: [X offset] [Y offset] [Blur size] [Colour];} Note: X indicates the displacement on the X axis and can be a negative value; Y indicates the displacement on the Y axis, which can be a negative value. Blur indicates the projection width, which cannot be a negative value. Color indicates the Projection Color.
Stacked multi-layer CSS projection
Although we do not need to stack multi-layer projection, it will have a better 3D effect through stack multi-layer projection.
Start creating 3D text
You may choose a color that is deeper than the text to use as the projection color, so in this example, I use white text and a little deeper gray as the projection color, in this example, I render the 3D effect of H2 text. The css code is as follows:
The copy code is as follows: h2 {text-shadow:
1px 1px 0 # CCC,
2px 2px 0 # CCC,/* end of 2 level deep gray shadow */
3px 3px 0 #444,
4px 4px 0 #444,
5px 5px 0 #444,
6px 6px 0 #444;/* end of 4 level deep dark shadow */} the effect is as follows: Well, you have created basic 3D text here. However, let's further implement the zoomed-in effect of text sliding over the mouse, and use the transision attribute of css to implement smooth fade-in and fade-out effects.
First, use the transform attribute to zoom in the font.
Copy the Code as follows: h2: hover {/* CSS3 Transform Effect */
-Webkit-transform: scale (1.2);/* Safari & Chrome */
-Moz-transform: scale (1.2);/* Firefox */
-O-transform: scale (1.2);/* Opera */}: Use the transition attribute to implement fade-in and fade-out.
Copy the Code as follows: h2 {/* CSS3 Transition Effect */
-Webkit-transition: all 0.12 s outgoing-out;/* Safari & Chrome */
-Moz-transition: all 0.12 s outgoing-out;/* Firefox */
-O-transition: all 0.12 s bytes-out;/* Opera */} Here, we use CSS3 to implement the 3D effect text, in addition, moving the mouse over enables font to zoom in and fade in and out, which is implemented with pure CSS.

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.