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

你可能感兴趣的文章
python 三大框架的 介绍。
查看>>
Python 下载的 11 种姿势,一种比一种高级!
查看>>
python读取一个文件夹下所有图片_初学Python-找出文件夹下的所有图片
查看>>
Python 中 3 个不可思议的返回功能
查看>>
python 中 dict 的另一种用法
查看>>
Python 中 PIL 读取图片出现异常旋转的解决方法
查看>>
python读取word表格内容(1)
查看>>
python 中os.path.join 双斜杠的解决办法
查看>>
python 中PIL.Image和OpenCV图像格式相互转换
查看>>
Python 中Semaphore 信号量对象、Event事件、Condition
查看>>
python 中with的使用及样例
查看>>
python读取wav文件并播放[pyaudio/wave]
查看>>
python读取txt文件的行数
查看>>
Python 中内置的最大堆 API
查看>>
Python 中只有一个 True 和一个 False 对象吗?
查看>>
python读取mtcars数据集并实现以下操作_关于数据处理。。,Python交流,技术交流区,鱼C论坛 - Powered by Discuz!...
查看>>
Python 中多线程与多处理之间的区别
查看>>
Python 中如何使用 lambda 函数
查看>>
Python 中如何创建多行字符串?
查看>>
Python 中如何处理异常?
查看>>