Home  >  Article  >  Web Front-end  >  针对不同浏览器内核的写法_html/css_WEB-ITnose

针对不同浏览器内核的写法_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:32:211711browse

针对不同浏览器内核的写法:
建议:尽可能的手写代码,可以有效的提高学习效率和深度。
现在使用的浏览器类型多种多样,对于浏览器者来说选择性提高了,也提高了竞争性,对于提供更为优质的功能有着极大地作用,但是对于开发者来说却是一个噩梦,在CSS中,有些属性使用W3C的写法在一些浏览器中并不能生效,需要使用单独针对某种浏览器内核的写法才可以,下面罗列一下针对各种浏览器的写法:

-webkit//Webkit内核,例如谷歌和Safari浏览器-moz//Gecko内核,例如火狐浏览器-o//Presto内核,例如Opera浏览器-ms//Trident内核,例如IE浏览器

也就是说在相应的属性名称前面添加上面罗列的前缀就可以了。
代码实例如下:

<!DOCTYPE html><html><head><meta charset=" utf-8"><meta name="author" content="http://www.softwhy.com/" /><title>蚂蚁部落</title><style type="text/css">div {  -webkit-border-radius: 30px;  width: 200px;  height: 200px;  background-color: #000;}</style></head><body><div></div></body></html>

以上代码只有在以Webkit为内核的浏览器中有圆角效果,在其他内核类型的浏览器中没有圆角效果。

原文地址是:http://www.softwhy.com/forum.php?mod=viewthread&tid=3372

更多内容可以参阅:http://www.softwhy.com/divcss/

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn