这是非常hacky,但我被难住了。我正在使用一个内部工具来创建一个网页。因此,由于这些工具的性质,我只能访问一些生成的HTML和CSS。
所以,强加在我身上的是HTML
<div class="example">
<div class="whatICanAccess">
</div>
</div>
我的CSS:
.example {
padding : 1.6em;
}
我唯一可以编辑我的CSS的地方是在“WhaticanAccess”HTML标记内,使用style=“foo”。
我是否可以以任何方式从外部元素(“example”)中删除填充?
我是否可以删除外部元素的填充,只影响“WhatICanAccess”的直接父元素?
Example是一个贯穿整个代码的类,我只想在一个特定的地方删除它--但是正如我所说的,我不能添加更具体的标识符/标记--我只能在这一个地方进行编辑。
更新
现在我有了这个HTML:
<div class="example">
<div class="moreSpecific" style=" padding: -1.8em;>
</div>
</div>
但是.example
的1. 6 em仍然是覆盖的,我在这里做错了什么?
2条答案
按热度按时间8yoxcaq71#
给予第1个地方一个单独的类,并给它负边距来平衡填充。
或者,使用
position: absolute
和width和height值,使用这两个值都不用担心不能访问父元素。尝试做一个JSFiddle,但显然他们暂时删除了“保存”选项...
如果您必须使用内联CSS...
14ifxucb2#
如果知道example的
id
,就可以使用document.getElementById('example').style.padding='0px';
给你的html一个负的边距或者填充也可以。