Need to override css with !important
-
Looking for a solution.
I am using a little jQuery program I wrote which adds buttons to the top of the table to scroll left or right. I use this often, because many people don’t notice the scrollbar at the bottom of the table on mobile devices.
Problem is that there is a piece of css in Tablepress which will not allow this due to the use of !important. I have confirmed this is the problem. When removed, my code works. I also attempted to use the jQuery scrollLeft and scrollRight. This also does not work either and nor does custom css.
Here is the Tablepress css that is problematic:
.dataTables_wrapper .tablepress {
clear: both;
margin: 0 !important;
}Here is my code:
<script>
jQuery(“.mobile_right”).click(function () {
var leftPos = parseInt(jQuery(“.entry-post table”).css(“margin-left”));
var entryWidth = parseInt(jQuery(“.entry-post”).width());
var tableWidth = parseInt(jQuery(“.tablepress-id-1”).width());
var etdiff = entryWidth – tableWidth;
if (leftPos >= 0) {
jQuery(“.tablepress-id-1”).animate({marginLeft: leftPos + etdiff}, 800);
}
});
jQuery(“.mobile_left”).click(function () {
var leftPos = parseInt(jQuery(“.tablepress-id-1”).css(“margin-left”));
if (leftPos < 0) {
jQuery(“.entry-post .tablepress-id-1”).animate({marginLeft: 0}, 800);}
});
</script>I would be grateful to anyone who has a solution. I might have to do it another way and lose the animation effect.
Thanks,
Andrea
- The topic ‘Need to override css with !important’ is closed to new replies.