如果未启用javascript,请定义css

栏目: CSS · 发布时间: 7年前

内容简介:如果没有启用javascript,我想定义.exampleclass img {height:250px}.无论如何他们在javascript / jquery中撤消这个?翻译自:https://stackoverflow.com/questions/4665748/define-css-if-javascript-is-not-enabled

如果没有启用javascript,我想定义.exampleclass img {height:250px}.无论如何他们在javascript / jquery中撤消这个?

你可以使用HTML的noscript标签.

<noscript>
    <style type="text/css">
        .exampleclass img {height:250px}
    </style>
</noscript>

编辑:我实际上将斯蒂芬的回答视为最好的.虽然上述方法可能有效,但可能无效/遵循最佳做法.

斯蒂芬回答:

put a “no-js” class on your body element, and then remove it with JS at load, and use .no-js in the selector for your CSS

该类也可以放在你的html元素上,然后在JavaScript不可用时应该出现的所有样式都可以在选择器之前以html.no-js作为前缀.例如,这就是 HTML5 Boiler Plate 所做的.

翻译自:https://stackoverflow.com/questions/4665748/define-css-if-javascript-is-not-enabled


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Release It!

Release It!

Michael T. Nygard / Pragmatic Bookshelf / 2007-03-30 / USD 34.95

“Feature complete” is not the same as “production ready.” Whether it’s in Java, .NET, or Ruby on Rails, getting your application ready to ship is only half the battle. Did you design your system to......一起来看看 《Release It!》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器