成都创新互联网站制作重庆分公司

CSS常用的前端效果有哪些

本文小编为大家详细介绍“CSS常用的前端效果有哪些”,内容详细,步骤清晰,细节处理妥当,希望这篇“CSS常用的前端效果有哪些”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。

创新互联建站服务项目包括环翠网站建设、环翠网站制作、环翠网页制作以及环翠网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,环翠网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到环翠省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!

1、禁止选择文本

  1. body {

  2. -webkit-touch-callout: none;

  3. -webkit-user-select: none;

  4. -khtml-user-select: none;

  5. -moz-user-select: none;

  6. -ms-user-select: none;

  7. user-select: none;

  8. }

2、在可打印的网页中显示URLs

  1. @media print {

  2. a:after {

  3. content: " [" attr(href) "] ";

  4. }

  5. }

3、深灰色的点击渐变按钮

  1. .graybtn {

  2. -moz-box-shadow:inset 0px 1px 0px 0px #ffffff;

  3. -webkit-box-shadow:inset 0px 1px 0px 0px #ffffff;

  4. box-shadow:inset 0px 1px 0px 0px #ffffff;

  5. background:-webkit-gradient( linear, left top, left bottombottom, color-stop(0.05, #ffffff), color-stop(1, #d1d1d1) );

  6. background:-moz-linear-gradient( center top, #ffffff 5%, #d1d1d1 100% );

  7. filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#d1d1d1');

  8. background-color:#ffffff;

  9. -moz-border-radius:6px;

  10. -webkit-border-radius:6px;

  11. border-radius:6px;

  12. border:1px solid #dcdcdc;

  13. display:inline-block;

  14. color:#777777;

  15. font-family:arial;

  16. font-size:15px;

  17. font-weight:bold;

  18. padding:6px 24px;

  19. text-decoration:none;

  20. text-shadow:1px 1px 0px #ffffff;

  21. }

  22. .graybtn:hover {

  23. background:-webkit-gradient( linear, left top, left bottombottom, color-stop(0.05, #d1d1d1), color-stop(1, #ffffff) );

  24. background:-moz-linear-gradient( center top, #d1d1d1 5%, #ffffff 100% );

  25. filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#d1d1d1', endColorstr='#ffffff');

  26. background-color:#d1d1d1;

  27. }

  28. .graybtn:active {

  29. position:relative;

  30. top:1px;

  31. }

4、网页顶部盒阴影

  1. body:before {

  2. content: "";

  3. position: fixed;

  4. top: -10px;

  5. left: 0;

  6. width: 100%;

  7. height: 10px;

  8.  

  9. -webkit-box-shadow: 0px 0px 10px rgba(0,0,0,.8);

  10. -moz-box-shadow: 0px 0px 10px rgba(0,0,0,.8);

  11. box-shadow: 0px 0px 10px rgba(0,0,0,.8);

  12. z-index: 100;

  13. }

5、在可点击的项目上强制手型

  1. a[href], input[type='submit'], input[type='image'], label[for], select, button, .pointer {

  2. cursor: pointer;

  3. }

6、CSS3 鲜艳的输入(边框渐变)

  1. input[type=text], textarea {

  2. -webkit-transition: all 0.30s ease-in-out;

  3. -moz-transition: all 0.30s ease-in-out;

  4. -ms-transition: all 0.30s ease-in-out;

  5. -o-transition: all 0.30s ease-in-out;

  6. outline: none;

  7. padding: 3px 0px 3px 3px;

  8. margin: 5px 1px 3px 0px;

  9. border: 1px solid #ddd;

  10. }

  11.  

  12. input[type=text]:focus, textarea:focus {

  13. box-shadow: 0 0 5px rgba(81, 203, 238, 1);

  14. padding: 3px 0px 3px 3px;

  15. margin: 5px 1px 3px 0px;

  16. border: 1px solid rgba(81, 203, 238, 1);

  17. }

7、三角形列表项目符号

  1. ul {

  2. margin: 0.75em 0;

  3. padding: 0 1em;

  4. list-style: none;

  5. }

  6. li:before {

  7. content: "";

  8. border-color: transparent #111;

  9. border-style: solid;

  10. border-width: 0.35em 0 0.35em 0.45em;

  11. display: block;

  12. height: 0;

  13. width: 0;

  14. left: -1em;

  15. top: 0.9em;

  16. position: relative;

  17. }

8、内部CSS3 盒阴影

  1. #mydiv {

  2. -moz-box-shadow: inset 2px 0 4px #000;

  3. -webkit-box-shadow: inset 2px 0 4px #000;

  4. box-shadow: inset 2px 0 4px #000;

  5. }

9、外部CSS3 盒阴影

  1. #mydiv {

  2. -webkit-box-shadow: 0 2px 2px -2px rgba(0, 0, 0, 0.52);

  3. -moz-box-shadow: 0 2px 2px -2px rgba(0, 0, 0, 0.52);

  4. box-shadow: 0 2px 2px -2px rgba(0, 0, 0, 0.52);

  5. }

10、@font-face模板

  1. @font-face {

  2. font-family: 'MyWebFont';

  3. src: url('webfont.eot'); /* IE9 Compat Modes */

  4. src: url('webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */

  5. url('webfont.woff') format('woff'), /* Modern Browsers */

  6. url('webfont.ttf') format('truetype'), /* Safari, Android, iOS */

  7. url('webfont.svg#svgFontName') format('svg'); /* Legacy iOS */

  8. }

  9.  

  10. body {

  11. font-family: 'MyWebFont', Arial, sans-serif;

  12. }

11、CSS3渐变模板

  1. #colorbox {

  2. background: #629721;

  3. background-image: -webkit-gradient(linear, left top, left bottombottom, from(#83b842), to(#629721));

  4. background-image: -webkit-linear-gradient(top, #83b842, #629721);

  5. background-image: -moz-linear-gradient(top, #83b842, #629721);

  6. background-image: -ms-linear-gradient(top, #83b842, #629721);

  7. background-image: -o-linear-gradient(top, #83b842, #629721);

  8. background-image: linear-gradient(top, #83b842, #629721);

  9. }

12、CSS3:全屏背景

  1. html {

  2. background: url('images/bg.jpg') no-repeat center center fixed;

  3. -webkit-background-size: cover;

  4. -moz-background-size: cover;

  5. -o-background-size: cover;

  6. background-size: cover;

  7. }

13、锚链接伪类

  1. a:link { color: blue; }

  2. a:visited { color: purple; }

  3. a:hover { color: red; }

  4. a:active { color: yellow; }

14、图片边框偏光

  1. img.polaroid {

  2. background:#000; /*Change this to a background image or remove*/

  3. border:solid #fff;

  4. border-width:6px 6px 20px 6px;

  5. box-shadow:1px 1px 5px #333; /* Standard blur at 5px. Increase for more depth */

  6. -webkit-box-shadow:1px 1px 5px #333;

  7. -moz-box-shadow:1px 1px 5px #333;

  8. height:200px; /*Set to height of your image or desired div*/

  9. width:200px; /*Set to width of your image or desired div*/

  10. }

15、通用媒体查询

  1. /* Smartphones (portrait and landscape) ----------- */

  2. @media only screen

  3. and (min-device-width : 320px) and (max-device-width : 480px) {

  4. /* Styles */

  5. }

  6.  

  7. /* Smartphones (landscape) ----------- */

  8. @media only screen and (min-width : 321px) {

  9. /* Styles */

  10. }

  11.  

  12. /* Smartphones (portrait) ----------- */

  13. @media only screen and (max-width : 320px) {

  14. /* Styles */

  15. }

  16.  

  17. /* iPads (portrait and landscape) ----------- */

  18. @media only screen and (min-device-width : 768px) and (max-device-width : 1024px) {

  19. /* Styles */

  20. }

  21.  

  22. /* iPads (landscape) ----------- */

  23. @media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape) {

  24. /* Styles */

  25. }

  26.  

  27. /* iPads (portrait) ----------- */

  28. @media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait) {

  29. /* Styles */

  30. }

  31.  

  32. /* Desktops and laptops ----------- */

  33. @media only screen and (min-width : 1224px) {

  34. /* Styles */

  35. }

  36.  

  37. /* Large screens ----------- */

  38. @media only screen and (min-width : 1824px) {

  39. /* Styles */

  40. }

  41.  

  42. /* iPhone 4 ----------- */

  43. @media only screen and (-webkit-min-device-pixel-ratio:1.5), only screen and (min-device-pixel-ratio:1.5) {

  44. /* Styles */

  45. }

16、跨浏览器透明

  1. .transparent {

  2. filter: alpha(opacity=50); /* internet explorer */

  3. -khtml-opacity: 0.5; /* khtml, old safari */

  4. -moz-opacity: 0.5; /* mozilla, netscape */

  5. opacity: 0.5; /* fx, safari, opera */

  6. }

17、用CSS动画实现省略号动画

  1. .loading:after {

  2. overflow: hidden;

  3. display: inline-block;

  4. vertical-align: bottombottom;

  5. animation: ellipsis 2s infinite;

  6. content: "‚6"; /* ascii code for the ellipsis character */

  7. }

  8. @keyframes ellipsis {

  9. from {

  10. width: 2px;

  11. }

  12. to {

  13. width: 15px;

  14. }

  15. }

18、制造模糊文本

  1. .blurry-text {

  2. color: transparent;

  3. text-shadow: 0 0 5px rgba(0,0,0,0.5);

  4. }

19、包裹长文本 文本过长自动换行不会穿破盒子

  1. pre {

  2. whitewhite-space: pre-line;

  3. word-wrap: break-word;

  4. }

20、背景渐变色

  1. button {

  2. background-image: linear-gradient(#5187c4, #1c2f45);

  3. background-size: auto 200%;

  4. background-position: 0 100%;

  5. transition: background-position 0.5s;

  6. }

  7. button:hover {

  8. background-position: 0 0;

  9. }

21、内容可编辑(contenteditable="true")

    • 悼念遇难香港同胞
    • 深圳特区30周年
    • 伊春空难

22、输入框改变placeholder字体颜色

  1. ::-webkit-input-placeholder {

  2. color: red;

  3. }

  4. :-moz-placeholder {

  5. color: red;

  6. }

  7. ::-moz-placeholder{

  8. color: red;

  9. }

  10. :-ms-input-placeholder {

  11. color: red;

  12. }

读到这里,这篇“CSS常用的前端效果有哪些”文章已经介绍完毕,想要掌握这篇文章的知识点还需要大家自己动手实践使用过才能领会,如果想了解更多相关内容的文章,欢迎关注创新互联行业资讯频道。


文章名称:CSS常用的前端效果有哪些
文章来源:http://cxhlcq.com/article/pogsdc.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部