Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to override max-width for specific div?

Tags:

css

I am searching for the following solution. In my CSS I have the following:

img, a img { 
    max-width: 100%;
    vertical-align: middle; 
}

This code is necessary for my WordPress theme and responsive web design. Now I want to override max-width property to auto. When I do this, it doesn't override:

#pixel-perfect img {
    max-width: auto !important;
    position: absolute;
    margin: -200px 0 0 -140px;
    z-index: -9999;
}

What did I do wrong?

like image 389
Caspert Avatar asked Nov 10 '13 19:11

Caspert


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.

Does Max-Width override width?

max-width overrides width , but min-width overrides max-width .

How do I make div not expand with content?

You can simply use the CSS display property with the value inline-block to make a <div> not larger than its contents (i.e. only expand to as wide as its contents).


1 Answers

Are you just looking to unset the max-width property? If so, try:

#pixel-perfect img {
    max-width: none;
}
like image 171
SeeMeCode Avatar answered Oct 17 '22 20:10

SeeMeCode