博客
关于我
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/

你可能感兴趣的文章
npm前端包管理工具简介---npm工作笔记001
查看>>
npm包管理深度探索:从基础到进阶全面教程!
查看>>
npm升级以及使用淘宝npm镜像
查看>>
npm发布包--所遇到的问题
查看>>
npm发布自己的组件UI包(详细步骤,图文并茂)
查看>>
npm和yarn清理缓存命令
查看>>
npm和yarn的使用对比
查看>>
npm如何清空缓存并重新打包?
查看>>
npm学习(十一)之package-lock.json
查看>>
npm安装 出现 npm ERR! code ETIMEDOUT npm ERR! syscall connect npm ERR! errno ETIMEDOUT npm ERR! 解决方法
查看>>
npm安装crypto-js 如何安装crypto-js, python爬虫安装加解密插件 找不到模块crypto-js python报错解决丢失crypto-js模块
查看>>
npm安装教程
查看>>
npm报错Cannot find module ‘webpack‘ Require stack
查看>>
npm报错Failed at the node-sass@4.14.1 postinstall script
查看>>
npm报错fatal: Could not read from remote repository
查看>>
npm报错File to import not found or unreadable: @/assets/styles/global.scss.
查看>>
npm报错unable to access ‘https://github.com/sohee-lee7/Squire.git/‘
查看>>
npm淘宝镜像过期npm ERR! request to https://registry.npm.taobao.org/vuex failed, reason: certificate has ex
查看>>
npm版本过高问题
查看>>
npm的“--force“和“--legacy-peer-deps“参数
查看>>