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
- <! Doctype html>
- <Html>
- <Head>
- <Title> Creating non-selectable text using CSS </title>
- <Style type = "text/css">
- Div {
- Margin-bottom: 20px;
- Padding: 10px;
- Background: rgba (10%, 10%, 10%, 0.3 );
- -Moz-border-radius: 15px;
- Border-radius: 15px;
- }
- Div # d2 {
- -Moz-user-select: none;
- -Khtml-user-select: none;
- User-select: none;
- Font-style: italic;
- }
- </Style>
- </Head>
- <Body>
- <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>
- <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>
- <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>
- </Body>
- </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.