当前位置: 首页 > news >正文

什么是css初始化

什么是css初始化

CSS初始化是指重设浏览器的样式。

因为浏览器的兼容问题,不同浏览器对有些标签的默认值是不同的,如果没对CSS初始化往往会出现浏览器之间的页面显示差异。

每次新开发网站或新网页时候通过初始化CSS样式的属性,为我们将用到的CSS或html标签更加方便准确,使得我们开发网页内容时更加方便简洁,同时减少CSS代码量,节约网页下载时间。

css初始化的好处:提高编码质量

初始化CSS为我们节约网页代码,节约网页下载时间;还会使得我们开发网页内容时更加方便简洁,不用考虑很多。

如果不初始化,整个页面做完会很糟糕,重复的css样式很多。

我们在开发比较复杂的网页时候就不会知道自己是否已经设置了此处的CSS属性,是否和前面的CSS属性相同,是否统一整个网页的风格和样式。

(学习视频分享:css视频教程)

最简单的初始化方法就是: * {padding: 0; margin: 0;} 。有很多人也是这样写的。

这确实很简单,但有人就会感到疑问:*号这样一个通用符在编写代码的时候是快,但如果网站很大,CSS样式表文件很大,这样写的话,他会把所有的标签都初始化一遍,这样就大大的加强了网站运行的负载,会使网站加载的时候需要很长一段时间。

我们可以直接使用下面的代码初始化css。

css初始化代码:

/*css 初始化 */
html, body, ul, li, ol, dl, dd, dt, p, h1, h2, h3, h4, h5, h6, 
form, fieldset, legend, img { margin:0; padding:0; } 
fieldset, img,input,button { border:none; padding:0;margin:0;outline-style:none; }
ul, ol { list-style:none; }
input { padding-top:0; padding-bottom:0; font-family: "SimSun","宋体";}
select, input { vertical-align:middle; }
select, input, textarea { font-size:12px; margin:0; }
textarea { resize:none; }
img {border:0;    vertical-align:middle;}
table { border-collapse:collapse; }
body {font:12px/150% Arial,Verdana,"\5b8b\4f53";color:#666;background:#fff
}
.clearfix:before,.clearfix:after{ content:""; display:table; 
} 
.clearfix:after{clear:both;} 
.clearfix{ *zoom:1;/*IE/7/6*/ 
} 
a{color:#666; text-decoration:none; }
a:hover{color:#C81623;}
h1,h2,h3,h4,h5,h6{text-decoration:none;font-weight:normal;}
s,i,em{font-style:normal;text-decoration:none;}
.col-red{color: #C81623!important;}
/*公共类*/
.w{width: 1210px;margin:0 auto;
}
.fl {float:left
}
.fr {float:right
}
.al {text-align:left
}
.ac {text-align:center
}
.ar {text-align:right
}
.hide {display:none
}

各大网站CSS初始化代码集合

CSS初始化可以简单快速的实现常用标签的属性设定,尽量减少各浏览器之间的兼容性问题

1、百度 CSS初始化 https://www.baidu.com

统一初始化


body, h1, h2, h3, h4, h5, h6, hr, p, blockquote, dl, dt, dd, ul, ol, li, pre, form, fieldset, legend, button, input, textarea, th, td {margin: 0;padding: 0}html {color: #000;overflow-y: scroll;overflow: -moz-scrollbars}body, button, input, select, textarea {font: 12px arial}h1, h2, h3, h4, h5, h6 {font-size: 100%}em {font-style: normal}small {font-size: 12px}ul, ol {list-style: none}a {text-decoration: none}a:hover {text-decoration: underline}legend {color: #000}fieldset, img {border: 0}button, input, select, textarea {font-size: 100%}table {border-collapse: collapse;border-spacing: 0}img {-ms-interpolation-mode: bicubic}textarea {resize: vertical}其他常用CSS样式.left {float: left}.right {float: right}.overflow {overflow: hidden}.hide {display: none}.block {display: block}.inline {display: inline}.error {color: #F00;font-size: 12px}label, button {cursor: pointer}.clearfix:after {content: '\\20';display: block;height: 0;clear: both}.clearfix {zoom: 1}.clear {clear: both;height: 0;line-height: 0;font-size: 0;visibility: hidden;overflow: hidden}.wordwrap {word-break: break-all;word-wrap: break-word}.s-yahei {font-family: arial, 'Microsoft Yahei', '微软雅黑'}

2、腾讯首页 CSS初始化 http://www.qq.com

统一初始化

body, dd, dl, fieldset, form, h1, h2, h3, h4, h5, h6, input, legend, ol, p, select, td, textarea, th, ul {margin: 0;padding: 0}body {font: 12px SimSun, "Arial Narrow", HELVETICA;background: #fff;-webkit-text-size-adjust: 100%}a {color: #172c45;text-decoration: none}a:hover {color: #cd0200;text-decoration: underline}em {font-style: normal}li {list-style: none}img {border: 0;vertical-align: middle}table {border-collapse: collapse;border-spacing: 0}p {word-wrap: break-word}

其他常用CSS样式

.ind {text-indent: 2em}.ind10 {text-indent: 10px}.noborder {border: 0}.Q-red a, a.Q-red {color: #bd0a01 !important}.Q-black a, a.Q-black {color: #000 !important}.Q-bold {font-weight: 700 !important}.Q-pList ul:after, .Q-pList:after, .Q-tList ol:after, .Q-tList ul:after, .Q-tList:after, .Q-tpList ul:after, .Q-tpList:after, .Q-tpWrap:after, .bd:after, .cf:after, .ft:after, .hd:after, .layout:after {content: "";display: table;clear: both}.Q-pList, .Q-pList ul, .Q-tList, .Q-tList ol, .Q-tList ul, .Q-tpList, .Q-tpList ul, .Q-tpWrap, .bd, .cf, .ft, .hd, .layout {*zoom: 1}.chief, .fl, .layout .fl {float: left;display: inline}.extra, .fr, .layout .fr {float: right;display: inline}.fn {font-weight: 700}

3、360官网 CSS初始化 https://www.360.cn

统一初始化

td, body, th, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, legend, input, textarea, p, blockquote, th, td {padding: 0}body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, legend, input, textarea, p, blockquote, th, td {margin: 0}h1, h2, h3, h4, h5, h6 {font-size: 100%;font-weight: 400}ul, ol {list-style: none}

4、微博官网 CSS初始化 https://weibo.com

统一初始化

body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, legend, input, textarea, p, blockquote, th, td {margin: 0;padding: 0;}table {border-collapse: collapse;border-spacing: 0;}fieldset, img {border: 0;}address, caption, cite, code, dfn, em, th, var, i {font-style: normal;font-weight: normal;}ol, ul {list-style: none;}caption, th {text-align: left;}h1, h2, h3, h4, h5, h6 {font-size: 100%;font-weight: normal;}

其他常用CSS样式

q:before, q:after {content: '';}a:focus {outline-style: none;}abbr, acronym {border: 0;font-variant: normal;}sup {vertical-align: text-top;}sub {vertical-align: text-bottom;}input, textarea, select {font-family: inherit;font-size: inherit;font-weight: inherit;*font-size: 100%;}textarea {resize: none}input::-ms-clear {display: none;}body {font: 12px/1.3 Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif;overflow-x: hidden;color: #333;-webkit-font-smoothing: antialiased;}::selection {background: #eb7350;color: #fff;}:focus {outline-color: #eb7350;}

5、淘宝官网 CSS初始化 https://www.taobao.com

统一初始化

blockquote, body, button, dd, dl, dt, fieldset, form, h1, h2, h3, h4, h5, h6, hr, input, legend, li, ol, p, pre, td, textarea, th, ul {margin: 0;padding: 0}body, button, input, select, textarea {font: 12px/1.5 tahoma, arial, 'Hiragino Sans GB', '\\5b8b\\4f53', sans-serif}h1, h2, h3, h4, h5, h6 {font-size: 100%}address, cite, dfn, em, var {font-style: normal}code, kbd, pre, samp {font-family: courier new, courier, monospace}small {font-size: 12px}ol, ul {list-style: none}a {text-decoration: none}a:hover {text-decoration: underline}sup {vertical-align: text-top}sub {vertical-align: text-bottom}legend {color: #000}fieldset, img {border: 0}button, input, select, textarea {font-size: 100%}table {border-collapse: collapse;border-spacing: 0}button {border-radius: 0;}

6、京东官网 CSS初始化 https://www.jd.com

统一初始化


* {margin: 0;padding: 0}em, i {font-style: normal}li {list-style: none}img {border: 0;vertical-align: middle}button {cursor: pointer}a {color: #666;text-decoration: none}a:hover {color: #e33333}button, input {font-family: Microsoft YaHei, Heiti SC, tahoma, arial, Hiragino Sans GB, \\5B8B\4F53, sans-serif}body {-webkit-font-smoothing: antialiased;background-color: #fff;font: 12px/1.5 Microsoft YaHei, Heiti SC, tahoma, arial, Hiragino Sans GB, \\5B8B\4F53, sans-serif;color: #666}

其他常用样式

.hide, .none {display: none}.clearfix:after {visibility: hidden;clear: both;display: block;content: ".";height: 0}.clearfix {*zoom: 1}

参考链接

https://www.php.cn/faq/473405.html
https://blog.csdn.net/heart_is_broken/article/details/126331482

相关文章:

什么是css初始化

什么是css初始化 CSS初始化是指重设浏览器的样式。 因为浏览器的兼容问题,不同浏览器对有些标签的默认值是不同的,如果没对CSS初始化往往会出现浏览器之间的页面显示差异。 每次新开发网站或新网页时候通过初始化CSS样式的属性,为我们将用…...

谁会成为第一个MoE大模型基座呢?重磅!Mixtral MoE 8x7B!!!

文章目录 谁会成为第一个MoE大模型基座呢?重磅!Mixtral MoE 8x7B!!!前言重磅!Mixtral MoE 8x7B!!!Mixtral是啥模型介绍模型结构长啥样?表现如何?可…...

Linux升级nginx版本

处于漏洞修复目的服务器所用nginx是1.16.0版本扫出来存在安全隐患,需要我们升级到1.17.7以上。 一般nginx默认在 /usr/local/ 目录,这里我的nginx是自定义的路径安装在 /app/weblogic/nginx 。 1.查看生产环境nginx版本 cd /app/weblogic/nginx/sbin/…...

人工智能|网络爬虫——用Python爬取电影数据并可视化分析

一、获取数据 1.技术工具 IDE编辑器:vscode 发送请求:requests 解析工具:xpath def Get_Detail(Details_Url):Detail_Url Base_Url Details_UrlOne_Detail requests.get(urlDetail_Url, headersHeaders)One_Detail_Html One_Detail.cont…...

mac苹果笔记本电脑如何强力删除卸载app软件?

苹果电脑怎样删除app?不是把app移到废纸篓就行了吗,十分简单呢! 其实不然,因为在Mac电脑上,删除应用程序只是删除了应用程序的主要组件。大多数时候,系统会有一个相当长的目录,包含所有与应用程…...

net6中使用MongoDB

目录 一、MongoDB是什么? 二、使用步骤 1.安装驱动 2.设置连接字符串、配置类 3.建立实体类 4.服务层 5.在Program添加服务 6.在Controller注入服务 总结 一、MongoDB是什么? MongoDB 是一个开源的、可扩展的、跨平台的、面向文档的非关系型数据库&…...

vue中yarn install超时问题

囚笼中的网络固然可以稳定局势,不让猴子们得以随时醒悟!给你吃的你就好好吃,不要有其他的翻然醒悟的时刻。无论如何,愚蠢的活着也是一种幸福,听着那些耐心寻味的统计幸福指数,我们不由的幸福的一批。。 最…...

vue3 引入 markdown编辑器

参考文档 安装依赖 pnpm install mavon-editor // "mavon-editor": "3.0.1",markdown 编辑器 <mavon-editor></mavon-editor>新增文本 <mavon-editor ref"editorRef" v-model"articleModel.text" codeStyle"…...

算法----K 和数对的最大数目

题目 给你一个整数数组 nums 和一个整数 k 。 每一步操作中&#xff0c;你需要从数组中选出和为 k 的两个整数&#xff0c;并将它们移出数组。 返回你可以对数组执行的最大操作数。 示例 1&#xff1a; 输入&#xff1a;nums [1,2,3,4], k 5 输出&#xff1a;2 解释&…...

RocketMQ-源码架构

源码环境搭建 1、主要功能模块 RocketMQ官方Git仓库地址&#xff1a;GitHub - apache/rocketmq: Apache RocketMQ is a cloud native messaging and streaming platform, making it simple to build event-driven applications. RocketMQ的官方网站下载&#xff1a;下载 | R…...

14-1、IO流

14-1、IO流 lO流打开和关闭lO流打开模式lO流对象的状态 非格式化IO二进制IO读取二进制数据获取读长度写入二进制数据 读写指针 和 随机访问设置读/写指针位置获取读/写指针位置 字符串流 lO流打开和关闭 通过构造函数打开I/O流 其中filename表示文件路径&#xff0c;mode表示打…...

每日一道算法题 1

借鉴文章&#xff1a;Java-敏感字段加密 - 哔哩哔哩 题目描述 给定一个由多个命令字组成的命令字符串&#xff1b; 1、字符串长度小于等于127字节&#xff0c;只包含大小写字母&#xff0c;数字&#xff0c;下划线和偶数个双引号 2、命令字之间以一个或多个下划线_进行分割…...

【网络奇缘】- 计算机网络|深入学习物理层|网络安全

​ &#x1f308;个人主页: Aileen_0v0&#x1f525;系列专栏: 一见倾心,再见倾城 --- 计算机网络~&#x1f4ab;个人格言:"没有罗马,那就自己创造罗马~" 回顾链接&#xff1a;http://t.csdnimg.cn/ZvPOS 这篇文章是关于深入学习原理参考模型-物理层的相关知识点&…...

❀expect命令运用于bash❀

目录 ❀expect命令运用于bash❀ expect使用原理 expet使用场景 常用的expect命令选项 Expect脚本的结尾 常用的expect命令选参数 Expect执行方式 单一分支语法 多分支模式语法第一种 多分支模式语法第二种 在shell 中嵌套expect Shell Here Document&#xff08;内…...

2023年团体程序设计天梯赛——总决赛题

F-L1-1 最好的文档 有一位软件工程师说过一句很有道理的话&#xff1a;“Good code is its own best documentation.”&#xff08;好代码本身就是最好的文档&#xff09;。本题就请你直接在屏幕上输出这句话。 输入格式&#xff1a; 本题没有输入。 输出格式&#xff1a; 在一…...

K8S 工具收集

杂货铺&#xff0c;我不用 K8S&#xff0c;把见过的常用工具放在这里&#xff0c;后面学的时候再来找 名称描述官网Pixie查看 k8s 的工具。集群性能、网络状态、pod 状态、热点图等HomeKubernetes Dashboard基于 Web 的 Kubernetes 集群用户界面。GithubGardenerSAP 开源的 K8…...

自动化测试之读取配置文件

前言&#xff1a; 在日常自动化测试开发工作中&#xff0c;经常要使用配置文件&#xff0c;进行环境配置&#xff0c;或进行数据驱动等。我们常常把这些文件放置在 resources 目录下&#xff0c;然后通过 getResource、ClassLoader.getResource 和 getResourceAsStream() 等方法…...

如何实现分布式调用跟踪?

分布式服务拆分以后&#xff0c;系统变得日趋复杂&#xff0c;业务的调用链也越来越长&#xff0c;如何快速定位线上故障&#xff0c;就需要依赖分布式调用跟踪技术。下面我们一起来看下分布式调用链相关的实现。 为什么需要分布式调用跟踪 随着分布式服务架构的流行&#xf…...

接口的性能优化(从前端、后端、数据库三个角度分析)

接口的性能优化&#xff08;前端、后端、数据库&#xff09; 主要通过三方面进行优化 前端后端数据库 前端优化 接口拆分 不要搞一个大而全的接口&#xff0c;要区分核心与非核心的接口&#xff0c;不然核心接口就会被非核心接口拖累 或者一个接口中大部分返回都很快&…...

区块链扩容问题研究【06】

1.Plasma&#xff1a;Plasma 是一种基于以太坊区块链的 Layer2 扩容方案&#xff0c;它通过建立一个分层结构的区块链网络&#xff0c;将大量的交易放到子链上进行处理&#xff0c;从而提高了以太坊的吞吐量。Plasma 还可以通过智能合约实现跨链交易&#xff0c;使得不同的区块…...

丹青识画快速部署:开箱即用,体验智能影像理解与书法生成

丹青识画快速部署&#xff1a;开箱即用&#xff0c;体验智能影像理解与书法生成 1. 产品概览&#xff1a;当AI遇见东方美学 丹青识画是一款融合深度学习与东方美学的智能影像理解系统。它能够像一位精通诗书画的文人雅士般&#xff0c;精准解读画面内容&#xff0c;并以行云流…...

如何快速提升Python开发效率:VS Code扩展终极指南

如何快速提升Python开发效率&#xff1a;VS Code扩展终极指南 【免费下载链接】pylance-release Documentation and issues for Pylance 项目地址: https://gitcode.com/gh_mirrors/py/pylance-release Python开发工具在当今编程世界中扮演着至关重要的角色&#xff0c;…...

新手入门指南:在快马平台上手把手实现openclaw基础功能

今天想和大家分享一个特别适合新手入门的机器人抓取项目——openclaw的基础实现。作为一个开源机器人抓取框架&#xff0c;openclaw结合了视觉识别和触觉反馈&#xff0c;是学习多模态控制的绝佳案例。我在InsCode(快马)平台上尝试实现了一个简化版本&#xff0c;整个过程对初学…...

如何通过ImageToSTL实现图像三维化?解锁创意设计新可能

如何通过ImageToSTL实现图像三维化&#xff1f;解锁创意设计新可能 【免费下载链接】ImageToSTL This tool allows you to easily convert any image into a 3D print-ready STL model. The surface of the model will display the image when illuminated from the left side.…...

令牌管理:AI开发中的成本控制与效率优化——Tiktokenizer全维度应用指南

令牌管理&#xff1a;AI开发中的成本控制与效率优化——Tiktokenizer全维度应用指南 【免费下载链接】tiktokenizer Online playground for OpenAPI tokenizers 项目地址: https://gitcode.com/gh_mirrors/ti/tiktokenizer 一、行业痛点分析&#xff1a;AI开发中的隐形成…...

如何用30美元自制AI智能眼镜?OpenGlass开源项目全解析

如何用30美元自制AI智能眼镜&#xff1f;OpenGlass开源项目全解析 【免费下载链接】OpenGlass Turn any glasses into AI-powered smart glasses 项目地址: https://gitcode.com/GitHub_Trending/op/OpenGlass 想象一下&#xff0c;你正在博物馆参观&#xff0c;眼前是一…...

LeaguePrank:英雄联盟段位修改与个性化展示完全指南

LeaguePrank&#xff1a;英雄联盟段位修改与个性化展示完全指南 【免费下载链接】LeaguePrank 项目地址: https://gitcode.com/gh_mirrors/le/LeaguePrank 想要在英雄联盟客户端中展示与众不同的段位和个性化信息吗&#xff1f;LeaguePrank 正是你需要的工具。这款开源…...

Llama-3.2V-11B-cot效果展示:模型对‘正常但可疑’图像模式的异常检测能力

Llama-3.2V-11B-cot效果展示&#xff1a;模型对正常但可疑图像模式的异常检测能力 1. 模型能力概览 Llama-3.2V-11B-cot是基于Meta Llama-3.2V-11B-cot多模态大模型开发的高性能视觉推理工具&#xff0c;专门针对双卡4090环境进行了深度优化。该模型具备以下核心能力&#xf…...

linux sed/awk命令检索区间日志的问题

开发时如果需要检索一段时间内或者某个批量执行期间的所有日志&#xff0c;也就是区间日志时&#xff0c;手动检索会有一些问题&#xff1a;如要查询一段时间前的日志&#xff08;比如归档日志&#xff09;&#xff0c;需要一页一页翻&#xff0c;费时且费眼睛使用grep筛选日志…...

RK3588 android12休眠唤醒后以太网不可用

现象&#xff1a;开机后连接网线可正常使用&#xff0c;系统休眠后再次唤醒后网络不通&#xff0c;等待约30秒后看门狗复位&#xff0c;gmac重新初始化后可继续使用。&#xff08;此问题还会导致屏幕唤醒点亮延时1-2秒&#xff09;日志&#xff1a;休眠唤醒后提示报错如下&…...