附加控件的CSS [英] Appended control's CSS

查看:81
本文介绍了附加控件的CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了一个JavaScript书签,已将div附加到当前页面.

I've developed a JavaScript Bookmarklet that have appended div to the current page.

但是问题是,当div及其内容由于页面的原始CSS代码而加载时(Bookmarklet也具有其自己的CSS),我的div的外观就会损坏.

But problem is that, when div and its content loaded because of pages' original CSS codes (Bookmarklet has its own CSS as well), my div's appearance corrupts.

我的意思是,在每个页面上,某些元素看起来都不同(有时标签的高度,有时textarea的背景色等)

I mean, on every page, some of elements looks different (sometimes labels' heights, sometimes textarea's backgroundcolor, etc.)

有没有办法纠正您所知道的此故障?它可以是CSS或JavaScript解决方案.

Is there a way to correct this fault that you know? It can be a CSS or JavaScript solution.

推荐答案

有什么办法可以纠正您所知道的此故障?

Is there any way to correct this fault that you know?

是的,在DIV和!important中定义每个相关属性:

Yes, define every relevant property inside the DIV and !important:

<div style="width: 300px !important; line-height: 1em !important....">

没有其他完美的故障保护方法.我见过的所有外部小部件都采用这种方式.

there is no other perfectly fail-safe way. All external widgets I've seen do it this way.

这篇关于附加控件的CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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