css怎么去掉默认样式

您所在的位置:网站首页 清除a默认样式的命令 css怎么去掉默认样式

css怎么去掉默认样式

2023-05-03 13:44| 来源: 网络整理| 查看: 265

css如何去掉默认样式

本文讲解"css怎么去掉默认样式",希望能够解决相关问题。

CSS去掉默认样式

在网站设计与开发过程中,重置或去掉浏览器自带的默认样式是一个基础但又必要的步骤。一些浏览器默认样式比如边距、补白、字体、颜色等,可能会与我们的样式冲突,因此我们需要自定义样式。

下面是一些方法来去掉浏览器自带的默认样式。

CSS Reset

CSS Reset是一个CSS文件,它的作用是重置默认样式,让所有的浏览器都使用相同的样式。他们通常包括重置边距、补白、字体、颜色等样式。

reset.css

html, body, div, span, applet, object, iframe, h2, h3, h4, h5, h6, h7, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, 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 {     margin: 0;     padding: 0;     border: 0;     outline: 0;     font-size: 100%;     vertical-align: baseline;     background: transparent;     box-sizing: border-box;     font-family: inherit;     font-weight: inherit;     font-style: inherit;     line-height: inherit; } /* remember to define focus styles! */ :focus {     outline: 0; } /* remember to highlight inserts somehow! */ ins {     text-decoration: none; } del {     text-decoration: line-through; } /* tables still need 'cellspacing="0"' in the markup */ table {     border-collapse: collapse;     border-spacing: 0; } /* inputs, textarea */ input[type="text"],input[type="password"], textarea {     margin: 0;     padding: 0;     border: none;     outline: none;     font-family: inherit;     font-size: 100%;     vertical-align: bottom;     box-sizing: border-box;     -webkit-appearance: none;     -moz-appearance: none;     appearance: none;     -webkit-border-radius: 0;     -moz-border-radius: 0;     border-radius: 0; } input[type="checkbox"], input[type="radio"] {     margin: 0;     padding: 0;     vertical-align: middle;     -webkit-appearance: none;     -moz-appearance: none;     appearance: none;     -webkit-border-radius: 0;     -moz-border-radius: 0;     border-radius: 0;     border: 1px solid #999;     width: 13px;     height: 13px;     outline: none; } /* buttons */ button {     margin: 0;     padding: 0;     border: none;     outline: none;     background: transparent;     font-family: inherit;     font-size: 100%;     vertical-align: middle;     box-sizing: border-box;     -webkit-appearance: none;     -moz-appearance: none;     appearance: none;     cursor: pointer; } /* images */ img {     border: none;     outline: none;     vertical-align: middle; }

如上重置,就可以清除所有默认的样式了。

Normalize.css

Normalize.css 是一个相对于 CSS Reset 更为友好的样式库,它不是清除默认样式,而是规范化不同浏览器的默认样式,让所有浏览器都会表现出相同的效果。同时,有些元素是必需增加默认修饰的,Normalize也会帮你完成。

下面是引用Normalize示例:

        This is paragraph text.

自定义

自定义默认样式,针对我们自身业务的需求,仅仅覆盖浏览器默认样式即可。例如我们针对默认链接的颜色:

a {     color: black;     text-decoration: none; } a:hover {     color: red;     text-decoration: underline; }

这样,我们就可以自定义默认链接样式。

关于 "css怎么去掉默认样式" 就介绍到此。希望多多支持编程宝库。

下一节:css怎么实现菜单导航Web 编程技术

css如何实现菜单导航:本文讲解"css怎么实现菜单导航",希望能够解决相关问题。一、HTML基础结构在开始编写CSS样式之前,我们需要先了解HTML基础结构。在本例中,我们需要创建一个菜单导航,并定义它的基础结构。下面是一个基本的HTML ...



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3