Override element.style using CSS
Although it's often frowned upon, you can technically use:
display: inline !important;
It generally isn't good practice but in some cases might be necessary. What you should do is edit your code so that you aren't applying a style to the <li>
elements in the first place.
How can I override inline styles with external CSS?
The only way to override inline style is by using !important
keyword beside the CSS rule. The following is an example of it.
div {
color: blue !important;
/* Adding !important will give this rule more precedence over inline style */
}
<div style="font-size: 18px; color: red;">
Hello, World. How can I change this to blue?
</div>
How to override CSS style assigned to element
If you use JS to set element style (i.e. ele.style.zIndex
), then '100 !important'
is not a legal value (while '100'
is), so the expression silently fails.
However, if you use ele.setAttribute('style', '.....')
, then !important
could be applied.
And, inline style has much higher previledge than css class, so you cannot override it.
A much better approach would be, if you could edit HTML, use different class definitions.
<style>
.undercover { z-index: -20; }
.cover { z-index: 100; }
</style>
<div class="AJaXBusy undercover">
Then change class name when you want to make it
var ajaxBusy = document.querySelector('.AJaXBusy')
ajaxBusy.classList.remove('undercover')
ajaxBusy.classList.add('cover')
Related Topics
Can't Get My Div to Stay Fixed with Layout
Stopping Content from Getting Pushed Down Due to Overlap in Bootstrap
How to Achieve This Visual Using CSS
P Tags Appearing Lower in Firefox Than in Internet Explorer, Using CSS
CSS Attribute Selector Class Starts with But Not Equals To
Color Change of Navigation Buttons When Scrolling Up and When Scrolling Down
How to Add Second Level to a Submenu in a Dropdown Navigation CSS
Site Doesn't Look Right in Mobile Browser
What Is Wrong with My CSS? Active Links Not Changing Color
When Using Grid 960, How to Still Have a 100% Width Header Section
About Responsive Sites, Pixels, and Density
Center Vertically The Content of a Div ( Not by Line-Height )
How to Keep Mat-Datepicker Calender Open, Even After Selecting a Date from Calendar
How to Float Two Divs Side-By-Side Without Specifying a Width
How to Build a Two Column Fluid Layout with Twitter Bootstrap V3.0