0

This inline CSS is generated by jssor-slider,

position: absolute; 
top: 0px; 
left: 0px; 
width: 1500px;
height: 700px; 
transform-origin: 0px 0px 0px; 
transform: scale(0.876644);

and I want to override it with,

position: absolute; 
top: 0px; 
left: 0px; 
width: 100%; 
height: 700px; 

I tried it by the following,

$('#slider_container').width('100%');
$('#slider_container > div').css({'position': 'absolute', 'top': '0px', 'left':' 0px', 'width':' 10%', 'height':' 700px'});

I was successful, but this always remain.

transform-origin: 0px 0px 0px; 
transform: scale(0.876644);

How to remove this using jQuery?

3
  • 2
    When you say "inline css", do you mean that this is within <style></style> tags, or that it's within a style attribute on an html element? Commented Aug 15, 2016 at 14:54
  • Its like <div style="css here" >.. Commented Aug 15, 2016 at 15:09
  • 1
    you could flush the data in the style attribute first, then add what you need $('#slider_container').attr('style', '') Working fiddle Commented Aug 15, 2016 at 15:41

2 Answers 2

2

Just set the transform back to its default value. Which for transform is scale(1), and for transform-origin is 50% 50% 0.

jQuery

$('#slider_container > div').css({'transform': 'scale(1)', 'transform-origin': '50% 50% 0'});

JSFiddle (Before)

JSFiddle (After)

*Note This solution is acceptable if the styles are defined from a stylesheet. Otherwise, if they are defined inline (which was recently clarified by the OP), then Rudi Urbanek's solution would be ideal.

$('#slider_container > div').removeAttr("style");
Sign up to request clarification or add additional context in comments.

Comments

1

an easy solution is to first remove the inline style attribute before adding your new style.

$('#slider_container > div').removeAttr("style");
$('#slider_container > div').css({'position': 'absolute', 'top': '0px', 'left':' 0px', 'width':' 10%', 'height':' 700px'});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.