• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 226
  • Last Modified:

Overriding Inline Styles

This is a new one to me. I have a wordpress website site up here:

Learn to Earn

As you can see I have a featured slider on the home page. That slider is invoking images and using a "background-image" inline style to serve them up. This is the code that is being presented:

element.style {
    background-image: url("http://learntoearndayton.org/wp-content/uploads/2013/10/slider-photos_22-750x400.jpg");
    background-position: left top;
    height: 400px;
    position: relative;
    width: 750px;
}

Open in new window


The class that encloses this is class="coin-slider". My issue is this:

When I am viewing this on an iphone, the fixed 750 x 400 image is too big. However, I cannot seem to override this with CSS. Is it possible to override the inline style background image with CSS?

Pat
0
mcpilot1
Asked:
mcpilot1
  • 3
  • 2
1 Solution
 
leakim971PluritechnicianCommented:
add !important at the end

element.style {
    background-image: url("http://learntoearndayton.org/wp-content/uploads/2013/10/slider-photos_22-750x400.jpg") !important;
0
 
mcpilot1Author Commented:
i am not sure I explained fully. The 750 x 400 is fine for the full site. I need to scale those images for the mobile site. I can't scale a background image using CSS when it's an inline style, at least I have not been able to do that. That's what I need to resolve.
0
 
leakim971PluritechnicianCommented:
you can replace background-image with jquery:

$(document).ready(function() {

if (screen.width<750||screen.height<400) {
      $(".coin-slider").css("background-image", "url('http://learntoearndayton.org/wp-content/uploads/2013/10/slider-photos_22-smallOne.jpg')");
}

});
0
 
mcpilot1Author Commented:
is it possible to replace all of the images in that case? there are a number of them that rotate through,

Pat
0
 
leakim971PluritechnicianCommented:
$(document).ready(function() {

if (screen.width<750||screen.height<400) {
      $(".coin-slider").addClass(".coincoin-slider");
}

});

Open in new window


.coincoin-slider {
    background-image: url("http://learntoearndayton.org/wp-content/uploads/2013/10/slider-photos_22-smallOne.jpg") !important;
}
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now