Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the common CSS HACK problems and how to solve them?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

本篇内容介绍了"常用的CSS HACK问题有哪些及怎么解决"的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

1、樊篱IE浏览器(也就是IE下不体现)

*:lang(zh) select {font:12px !important;} /*FF的专一使用*/

select:empty {font:12px !important;} /*safari可见*/

这里select是决意符,遵照环境变卦。第二句是MAC上safari浏览器独占的。

2、仅IE7识别hack

*+html {…}

私下里临需求只针对IE7做花色的时辰就能够接纳这个HACK。

3、IE6及IE6下列辨认CSS HACK

* html {…}

这个中央要格外注意很多地主都写了是IE6的HACK确实IE5.x同样可以识别这个HACK。其它阅读器不识别。

html/**/ >body select {……}

这句和上一句的浸染相同。

4、仅IE6不识别div hack

select { display /*IE6不识别*/:none;}

这里主要是通过CSS表述分隔隔离分散一个属性和值,流释在冒号前。

5、仅IE6识别支持

.yangshi{_height:20px;}

这里IE6赞成识别CSS属性前"_"短下划线。

6、仅IE6和IE5不识别

select/**/ { display /*IE6,IE5不识别*/:none;}

这里与上面一句分歧的是在决意符和花括号之间多了一个CSS告白。

7、仅IE5不识别

select/*IE5不识别*/ { display:none;}

这一句是在上一句中去掉了属性区的疏解。只要IE5不识别

8、盒模型筹划门径

selct {width:IE5.x宽度; voice-family :"\"}\""; voice-family:inherit; width:正确宽度;}

盒模型的铲除门径不是颠末!important来处理的。这点要了解。

9、肃除浮动

select:after {content:"."; display:block; height:0; clear:both; visibility:hidden;}

在Firefox中,当子级都为浮动时,那末父级的高度就无奈纯粹的包住整个子级,那么这时候用这个肃清浮动的HACK来对父级做一次定义,那么便可以办理这个问题 。

10、截字省略号

select { -o-text-overflow:ellipsis; text-overflow:ellipsis; white-space:nowrap; overflow:hidden; }

这个是在越出长度后会自行的截掉多出局部的笔墨,并以省略号着末,很好的一个妙技。只不过今朝Firefox并不支持。

11、只需Opera识别

@media all and (min-width: 0px){ select {……} }

针对Opera涉猎器做独自的设定。

以上但凡写CSS中的一些HACK,这些都是用来规画局部的兼容性标题问题,假定祈望把兼容性的内容也分手出来,不妨试一下下面的几种过滤器。这些过滤器有的是写在CSS中颠末过滤器导入特另外花样,也有的是写在HTML中的经由前提来链接或是导入需要的补钉款式。

12、IE的if前提Hack

全数的IE可辨认

只有IE5.0可以辨认

IE5.0包换IE5.5均可以识别

仅IE6可识别

IE6以及IE6如下的IE5.x都可辨认

仅IE7可辨认

13、仅IE8兼容辨认

div{height:20px\9;}

这里的"\9"仅IE8支持辨认"常用的CSS HACK问题有哪些及怎么解决"的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注网站,小编将为大家输出更多高质量的实用文章!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report