去掉浏览器user agent stylesheet默认样式

user agent stylesheet是浏览器默认样式表,是浏览器默认样式,其中google中对body的默认样式为margin:8px。
这里写图片描述

解决办法:可是使用css默认样式重置
这是pc端可以使用的

@charset "utf-8";

/* CSS Document */
* { color:#444; }
body { font:12px/1.5 "微软雅黑",Arial,Tahoma, Helvetica,\5b8b\4f53, sans-serif; }
html,body,div,h1,h2,h3,h4,h5,h6,hr,p,blockquote,dl,dt,dd,ul,ol,li,pre,form,fieldset,object,code,em,span,var,legend,button,input,textarea,th,td,a,img,header,footer,nav,aside,audio,datalist,section { margin:0;padding:0;border:0;outline:0; }/*清除内外边距*/
h1,h2,h3,h4,h5,h6 { font-weight:normal;font-size:100%; }/*设置默认字体*/
:focus { outline:0; }
ul,ol,ul li,ol li { list-style: none; }/*重置列表*/
address,caption,cite,em,code,dfn,th,var { font-style:normal;font-weight:normal; }
form label { cursor:pointer; }
input,button,select,textarea { font-family:inherit;font-size:100%;outline:none; }
textarea { resize:none }
input { vertical-align:middle; }
img { border:0; }/*重置图片元素*/
table { border-collapse:collapse;border-spacing: 0; }/*重置表格*/
.l { float:left; }
.r { float:right; }
button,input[type="reset"],input[type="button"],input[type="submit"] { line-height:normal !important; }
a { text-decoration:none;}
a { color:#666;}
a:hover { text-decoration:underline; }
input { _filter:chroma(color=#000000); }
/*--清除浮动
------------------------------------------------------------------------------------------*/
.clearfix:after { clear:both;content:".";display:block;font-size:0;height:0;visibility:hidden; }
.clearfix:after { _zoom:1; }
.overflow { overflow:hidden; _zoom:1; }
.clear { clear:both; height:0;font-size:0; overflow:hidden; }

移动端重置样式

@charset "utf-8";
/* @group Public */
body,div,ul,ol,dl,li,dt,dd,h1,h2,h3,h4,p,form,iframe,input,textarea,a,span,em,strong,img,html,nav,header,article,button,footer,var {padding:0;margin:0;}
body { font:12px/1.2rem "Microsoft YaHei",tahoma,arial,sans-serif;min-width:320px;position:relative; }
form,input {background:none;border:none;}
ul,dl,ol {list-style-type:none;}
h1, h2, h3, h4, h5 { font:12px/1.2rem "Microsoft YaHei",arial,tahoma; }
a { text-decoration:none; }
a:hover,a:focus { outline:none; }
table { border-collapse:collapse;border-spacing:0; }
img { border:none; }
strong,b { font-weight:normal; }
em,i,var { font-style:normal; }
p { text-indent:0; }
.clear { clear:both;height:0;line-height:0;overflow:hidden;width:0; }
.clearfix:after { clear:both;content:".";display:block;font-size:0;height:0;visibility:hidden; }
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: CSS可以通过使用 font-family 属性来更改浏览器默认字体样式浏览器通常会根据操作系统的默认设置来显示文本,所以不同的浏览器可能会有不同的默认字体样式。 为了去除浏览器默认字体样式,可以将 font-family 属性设置为一个特定的字体名称或字体族。例如,可以使用以下CSS代码来去除浏览器默认样式: ``` body { font-family: Arial, sans-serif; } ``` 在这个例子中,字体名称 Arial 被指定为要应用于文本的首选字体。如果 Arial 不可用,浏览器将尝试使用 sans-serif 字体族中的任何可用字体。 通过使用特定的字体名称或字体族,可以确保浏览器不再使用默认的操作系统字体。这可以使网页设计师有更大的控制权,确保他们的网站在不同的浏览器中都具有一致的字体样式。 还可以通过其他CSS属性,如 font-size、font-weight 和 font-style 来更改文本样式。这些属性可以与 font-family 属性一起使用,以获得所需的字体样式。 总之,通过使用 font-family 属性,并指定一个特定的字体名称或字体族,可以轻松地去除浏览器默认字体样式,并在网页中应用自定义的字体样式。 ### 回答2: 要去除浏览器默认字体样式,可以通过设置CSS样式来实现。一般来说,不同的浏览器会有不同的默认字体样式。 首先,我们可以将`font-family`属性设置为一个特定的字体家族或者一个无字体样式的值,比如`sans-serif`,这样能够确保网页在不同的浏览器上显示一致的字体。例如: ```css body { font-family: sans-serif; } ``` 另外,为了确保字体大小一致,我们可以将`font-size`属性设置为一个具体的像素值或者一个相对值(如百分比)来避免默认字体大小的影响。例如: ```css p { font-size: 16px; } ``` 此外,我们还可以使用`font-weight`属性设置字体的粗细,以及使用`font-style`属性设置字体的样式。例如: ```css h1 { font-weight: bold; } em { font-style: italic; } ``` 最后,如果需要在整个页面或者特定区域设置的样式,可以使用`*`选择器来选择所有元素,然后将需要修改的字体属性设置为合适的值。例如: ```css * { font-family: sans-serif; font-size: 16px; } ``` 通过以上的CSS样式设置,我们可以去除浏览器默认字体样式,将字体样式统一并控制在自己设定的范围内,达到更好的页面展示效果。 ### 回答3: 要去除浏览器默认字体样式,可以使用CSS中的font-family属性来设置自定义字体,从而覆盖浏览器默认样式。 首先,我们可以将全局选择器(Global Selector)用于整个网页,来设置默认字体样式。例如,将字体设置为sans-serif(无衬线字体)或serif(衬线字体)。 ```css * { font-family: sans-serif; } ``` 这样,所有的元素都会应用这个字体样式。如果只想去除特定元素的默认字体样式,可以通过选择器来针对性地设置字体样式。 另外,可以通过使用CSS的reset样式表来重置所有浏览器默认样式,包括字体样式。这样可以确保在不同浏览器中都具有一致的字体样式。 ```css /* Reset Stylesheet */ body, p, h1, h2, h3, h4, h5, h6, ul, ol, li { margin: 0; padding: 0; font-family: sans-serif; } ``` 此外,还可以使用@font-face规则加载自定义字体文件(如Web字体),并将其应用于网页中的元素。这样可以完全自定义字体样式,不受浏览器默认样式的影响。 ```css @font-face { font-family: 'CustomFont'; src: url('customfont.woff') format('woff'); } body { font-family: 'CustomFont', sans-serif; } ``` 通过以上方法,我们可以有效地去除浏览器默认字体样式,并设置自定义的字体样式,以实现更好的网页视觉效果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值