温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

很实用的CSS的代码片段方法教程

发布时间:2021-10-23 18:03:15 阅读:158 作者:iii 栏目:web开发
前端开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

本篇内容介绍了“很实用的CSS的代码片段方法教程”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

CSS重置

这是CSS浏览器重置的基本和常见的CSS代码段

htmlbodydivspan, applet, objectiframeh2h3h4h5h6, h7, pblockquote, pre, aabbr, acronym, address, big, citecodedeldfnemimginskbdq, s, samp, small, strike, strong, sub, sup, tt, varb, u, i, center, dldtddolullifieldsetformlabellegendtablecaptiontbodytfoottheadtrthtdarticleasidecanvasdetails, embed, figurefigcaptionfooterheaderhgroupmenunav, output, ruby, sectionsummarytimemarkaudiovideo {      margin0;      padding0;      border0;      font-size100%;      font: inherit;      vertical-align: baseline;      outline: none;      -webkit-box-sizing: border-box;      -moz-box-sizing: border-box;      box-sizing: border-box; }  html {      height101%; }  body {      font-size62.5%;      line-height1;      font-family: Arial, Tahoma, sans-serif; }  articleasidedetailsfigcaptionfigurefooterheaderhgroupmenunavsection {      display: block; }  olul {      list-style: none; }  blockquoteq {      quotes: none; }  blockquote:beforeblockquote:afterq:beforeq:after {      content'';      content: none; }  strong {      font-weight: bold; }  table {      border-collapse: collapse;      border-spacing0; }  img {      border0;      max-width100%; }  p {      font-size1.2em;      line-height1.0em;      color#333; }

跨浏览器透明度设置

.transparent {          -ms-filter"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";/* IE 8 */          filteralpha(opacity=50); /* IE 5-7 */          -moz-opacity0.5;/* Netscape */          -khtml-opacity0.5/* Safari 1.x */         opacity0.5;  /* Good browsers */ }

常规媒体查询

/* Smartphones (portrait and landscape) ----------- */  @media only screen and (min-device-width : 320pxand (max-device-width : 480px) {     } /* Smartphones (landscape) ----------- */  @media only screen and (min-width : 321px) {     } /* Smartphones (portrait) ----------- */  @media only screen and (max-width : 320px) {      } /* iPads (portrait and landscape) ----------- */  @media only screen and (min-device-width : 768pxand (max-device-width : 1024px) {      } /* iPads (landscape) ----------- */  @media only screen and (min-device-width : 768pxand (max-device-width : 1024pxand (orientation : landscape) {      } /* iPads (portrait) ----------- */  @media only screen and (min-device-width : 768pxand (max-device-width : 1024pxand (orientation : portrait) {      } /* Desktops and laptops ----------- */  @media only screen and (min-width : 1224px) {     } /* Large screens ----------- */  @media only screen and (min-width : 1824px) {      } /* iPhone 4 ----------- */  @media only screen and (-webkit-min-device-pixel-ratio:1.5), only screen and (min-device-pixel-ratio:1.5) {     }

自定义选中文本

::selection {      background#51a351; }  ::-moz-selection {      background#51a351; }  ::-webkit-selection {      background#51a351; }

带CSS3的全屏背景

html {      backgroundurl('images/bg.jpg') no-repeat center center fixed;      -webkit-background-size: cover;      -moz-background-size: cover;      -o-background-size: cover;      background-size: cover; }

强制垂直滚动条

html {      height101%  }

文本首字母大写

p:first-letter {      display: block;      margin4px 0 0 4px;      float: left;      color#ff3366;      font-size5.3em;      font-family: Georgia, Times New Roman, serif; }

内外阴影

#mydiv {      -moz-box-shadow: inset 2px 0 4px #000;      -webkit-box-shadow: inset 2px 0 4px #000;      box-shadow: inset 2px 0 4px #000; }
#mydiv {      -webkit-box-shadow0 2px 2px -2px rgba(0000.52);      -moz-box-shadow0 2px 2px -2px rgba(0000.52);      box-shadow0 2px 2px -2px rgba(0000.52); }

语音气泡

.speech-bubble {     position: relative;     background#00aabb;     border-radius: .4em; }   .speech-bubble:after {     content'';     position: absolute;     bottom0;     left50%;     width0;     height0;     border30px solid transparent;     border-top-color#00aabb;     border-bottom0;     border-left0;     margin-left: -15px;     margin-bottom: -30px; }

自定义输入样式

input[type=text]textarea {      -webkit-transition: all 0.30s ease-in-out;      -moz-transition: all 0.30s ease-in-out;      -ms-transition: all 0.30s ease-in-out;      -o-transition: all 0.30s ease-in-out;      outline: none;      padding3px 0px 3px 3px;      margin5px 1px 3px 0px;      border1px solid #ddd; }  input[type=text]:focustextarea:focus {      box-shadow0 0 5px rgba(812032381);      padding3px 0px 3px 3px;      margin5px 1px 3px 0px;      border1px solid rgba(812032381); }

“很实用的CSS的代码片段方法教程”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

原文链接:https://www.toutiao.com/a6895004988574007816/

css
AI

开发者交流群×