Css如何使div内的非活动内容? [英] Css how to make inactive content inside div?

查看:87
本文介绍了Css如何使div内的非活动内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



假设有一个按钮,其命令为启用/禁用 。并且有一个div文本块。当按下启用/禁用按钮时,它是启用,您可以使用内部内容,但是当禁用时,您无法使用div块内的内容。



我想象为了在div块中创建不活动的内容,我们需要在其上添加另一个层,以防止在内容div块上编辑内容。



我很困惑如何实现这种功能。任何帮助将不胜感激。

解决方案

不使用覆盖,您可以使用 pointer-events:none 在CSS中的 div 中,但这在IE或Opera中不起作用。

  div.disabled 
{
pointer-events:none;

/ *为禁用效果* /
不透明度:0.5;
背景:#CCC;
}

参考资料


Could you please help with some examples, how to make content in some div block inactive using javascript?

Let's say there is a button with command "Enable / Disable". And there is one div block with some text. When pushing button "Enable / Disable", is it is "Enable", you can work with content inside, but when "Disable", you can't work with content inside div block.

I imagine in order to make inactive content inside div block, we need to put another layer upon that will prevent from editing content on the content div block.

I'm getting confused how to realize this kind of feature. Any help will be appreciated.

解决方案

Without using an overlay, you can use pointer-events: none on the div in CSS, but this does not work in IE or Opera.

div.disabled
{
  pointer-events: none;

  /* for "disabled" effect */
  opacity: 0.5;
  background: #CCC;
}

Reference

这篇关于Css如何使div内的非活动内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆