Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override a css value from a third party lib

Tags:

css

I'm using a third party css library for styling, but I'd like to specify a different min-height for a particular div.
The div is using themeRow class which has a number of attributes and sets:

min-height: 200px

In my case this is much too large, and i'd like to set a different value i.e

min-height: 75px

So i've defined some inline css but my value is being ruled out when rendered and the div still draws at min-height: 200px

Any way I can tell css to use my value instead of the third party value?

<style>
.bannerHeight {
    min-height: 75px;
}
</style>


<div class="themeRow bannerHeight"></div>
like image 594
bobbyrne01 Avatar asked Oct 31 '14 17:10

bobbyrne01


People also ask

How do I override an external CSS style?

Either apply the style="padding:0px;" on the content div inline (not recommended), or load your style after you load your external style sheet. Applying style="padding:0px;" to the body will only affect the body, and not apply to every element within it.

How do I override a value in CSS?

To override the CSS properties of a class using another class, we can use the ! important directive. In CSS, ! important means “this is important”, and the property:value pair that has this directive is always applied even if the other element has higher specificity.

How do you override a component in CSS?

So to override any CSS in an Angular project, go into styles. css and repeat the class selector until your CSS has a higher specificity than the original.


2 Answers

You can use !important to override the min-height: 200px value which is being assigned to your <div> by the third-party library. Try using this CSS:

<style>
.bannerHeight {
    min-height: 75px !important;
}
</style>
like image 95
Fahad Hasan Avatar answered Oct 10 '22 13:10

Fahad Hasan


IMHO it is better to use deeper levels over !important. If this is on your page 'main' then

<style>
.main .bannerHeight {
    min-height: 75px;
}
</style>

will override

<style>
.bannerHeight {
    min-height: 75px;
}
</style>

simply replace .main with whatever element is the parent to .bannerHeight, possibly just div .bannerHeight in this case as you hint. !important should be used for awkward situations where html css elements are being created dynamically, not for simple CSS overwriting as in this case.

But its your call.

like image 25
myol Avatar answered Oct 10 '22 12:10

myol