博客
关于我
css常用公共样式
阅读量:425 次
发布时间:2019-03-06

本文共 1977 字,大约阅读时间需要 6 分钟。

CSS reset与基本样式

在这个题目中,我们将深入探讨一些常用的CSS样式和布局技巧,这些技巧可以帮助开发者快速构建出美观且响应的网页。

CSS Reset

首先,我们需要确保不同浏览器在显示网页时不会出现样式差异。以下是一个基本的CSS reset方案:

* {    margin: 0;    padding: 0;    border: 0;    font-size: 100%;    font: inherit;    vertical-align: baseline;    outline: none;    -webkit-box-sizing: border-box;    -moz-box-sizing: border-box;    box-sizing: border-box;}

Body Styles

网页的布局从头开始,body的样式通常如下:

body {    font-size: 62.5%;    line-height: 1;    margin: 0 auto;    min-width: 320px;    max-width: 768px;    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Hiragino Sans GB", "Microsoft Yahei", "微软雅黑", Arial, Helvetica, STHeiti, sans-serif;    -webkit-text-size-adjust: 100% !important;    -webkit-user-select: none;    user-select: none;}

Layout与flexbox

在现代网页开发中,Flexbox是布局的首选工具。以下是一个简单的Flexbox示例:

.flex {    display: flex;    display: -ms-flex;    display: -webkit-flex;    display: box;    display: -ms-flexbox;    display: -webkit-flexbox;}

其他常用样式

以下是一些常用的样式技巧:

/* 无样式选择符 */html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {    margin: 0;    padding: 0;    border: 0;    font-size: 100%;    font: inherit;    vertical-align: baseline;    outline: none;    -webkit-box-sizing: border-box;    -moz-box-sizing: border-box;    box-sizing: border-box;}

模块化样式

将样式分成多个部分可以提高代码的可维护性。例如,可以将 typography, colors, layout 分别作为单独的样式文件管理。

未来方向

随着技术的发展,CSS的功能也在不断扩展。未来,布局引擎如Flexbox和Grid将成为主流,Grid的布局能力将进一步提升开发效率。此外,CSS变量也为样式管理带来了全新的可能性。

以上就是一些常用的CSS样式技巧和布局方法,希望对你有所帮助!

转载地址:http://kzsuz.baihongyu.com/

你可能感兴趣的文章
np.arange()和np.linspace()绘制logistic回归图像时得到不同的结果?
查看>>
npm error MSB3428: 未能加载 Visual C++ 组件“VCBuild.exe”。要解决此问题,1) 安装
查看>>
npm install digital envelope routines::unsupported解决方法
查看>>
npm install 卡着不动的解决方法
查看>>
npm install 报错 EEXIST File exists 的解决方法
查看>>
npm install 报错 ERR_SOCKET_TIMEOUT 的解决方法
查看>>
npm install 报错 fatal: unable to connect to github.com 的解决方法
查看>>
npm install 报错 no such file or directory 的解决方法
查看>>
npm install报错,证书验证失败unable to get local issuer certificate
查看>>
npm install无法生成node_modules的解决方法
查看>>
npm install的--save和--save-dev使用说明
查看>>
npm node pm2相关问题
查看>>
npm run build 失败Compiler server unexpectedly exited with code: null and signal: SIGBUS
查看>>
npm run build报Cannot find module错误的解决方法
查看>>
npm run build部署到云服务器中的Nginx(图文配置)
查看>>
npm run dev 报错PS ‘vite‘ 不是内部或外部命令,也不是可运行的程序或批处理文件。
查看>>
npm scripts 使用指南
查看>>
npm should be run outside of the node repl, in your normal shell
查看>>
npm start运行了什么
查看>>
npm WARN deprecated core-js@2.6.12 core-js@<3.3 is no longer maintained and not recommended for usa
查看>>