Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css: how to override max-width value with a larger (less restrictive) value

Tags:

css

overriding

I have a css file with this style:

.filefield-element .widget-edit {max-width: 70%;} 

I wanted to increase the max-width without modifying that css file, so I created a custom css file with this style:

.filefield-element .widget-edit {max-width: 99%;} 

In the "html/styles" pane, I see that the styles are listed in the correct order:

.filefield-element .widget-edit {     max-width: 99%; }  .filefield-element .widget-edit {     float: left;     max-width: 70%; } 

However, "max-width: 99%" is not overriding "max-width: 70%". It seems that the more restrictive value (70%) is used, even when the less-restrictive value (99%) comes first.

Is there a way to override a max-width value with a larger (less restrictive) value?

like image 213
moondog Avatar asked Feb 07 '11 17:02

moondog


People also ask

How do you overwrite max width in CSS?

The max-width property in CSS is used to set the maximum width of a specified element. The max-width property overrides the width property, but min-width will always override max-width whether followed before or after width in your declaration.

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.

Does Min width override max width?

Change the maximum width. max-width overrides width , but min-width overrides max-width .

Which CSS property can be used to set the maximum width of an element?

The CSS max-width property is used to set the maximum width of an element.


2 Answers

You can override (unset) max-width with

.foo{ max-width:none; } 

... to clear any inherited max-width.

like image 121
Jim Morrison Avatar answered Oct 01 '22 07:10

Jim Morrison


Try using !important, or selector with higher specificity.

like image 34
duri Avatar answered Oct 01 '22 06:10

duri