简体   繁体   English

删除图像的CSS(CSS是生成的代码的一部分)

[英]Remove CSS of an image (CSS is part of a generated code)

I am trying to remove the css of an image. 我正在尝试删除图像的CSS。 My actual code doesn't include this CSS, but it comes from a generate code. 我的实际代码不包含此CSS,但它来自生成代码。 I can't touch that neither modify anything that is related to the generared code. 我不能不修改与通用代码相关的任何内容。

This is my real code 这是我的真实代码

<div class="bubble">
  <img id="one" src="/static/webupload/MyronArtifacts/images/descarga.png" style='float: left;' alt="Quotes">
  <p id="comment11">I was very impressed with the unique design and high quality of this pen.
  </p>
</div>
<div class="quote_speech">
  <div class="name" id="author11">By PEDE</div>
  <div class="company" id="company11">September 25,2013</div>
</div>

This code is added to a div from the generated code name rightCol 此代码从生成的代码名称rightCol添加到div

And there is a CSS class declare the following way 并且有一个CSS类声明以下方式

#rightCol img{
  display:block;
  float:none;
  margin:0 auto 0 auto;
  position:relative;
  border:0;
  padding:3.5px 0;
  backgroun-color:#fff;
  width:166px
}

The issue is on width:166px. 问题出在width:166px上。 The bad new for me is I can't remove it manually(Generated code). 对我来说,不好的新消息是我无法手动将其删除(生成的代码)。

So I was thinking to use javascript for this. 所以我当时想为此使用javascript。 using this $('#one').hasClass('img') 使用此$('#one')。hasClass('img')

But this returns me false. 但这使我错了。

I did a demo getting in JS FIELD getting the CSS. 我在JS FIELD中获得了CSS的演示。 DEMO DEMO

If I remove the 166px from the CSS it works, but that solution is not available for me. 如果我从CSS中删除了166px,它可以工作,但是该解决方案对我不可用。 And the has class returns me false. 和has类返回我为假。 Wondering why? 想知道为什么?

Thanks in advance 提前致谢

Actually you can use !important to override this behavior but it is better to declare more specific rule rather than using !important 实际上,您可以使用!important来覆盖此行为,但是最好声明更具体的规则,而不是使用!important

#rightCol img#one {
   width: auto;
}

Demo 演示版

Hi I checked your demo page and just added one line to your document.ready function. 嗨,我检查了您的演示页面,并只向您的document.ready函数添加了一行。

$(document).ready(function () {
        $('#one').css('width', 'auto');
        randomtip();

    });

check and let me know if still problem exist. 检查并让我知道是否仍然存在问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM