Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to not inherit? or how to reset inherited width to the value before? (css)

I installed Thank you plugin but the button on my test site looks strange.

I found out why. Because it inherits #commentform textarea { width: 45%; } from my theme. If I remove the width from css the button looks ok. Any idea how I can fix that? Of course I do not want to remove width for #commentform textarea. Can I do something about that on css level of the button? Something like width:not-inherit; width:reset; I'd say that the width of the button wouldn't be declared at all if there was no #commentform textarea

like image 553
Radek Avatar asked Jun 03 '10 22:06

Radek


People also ask

Is width inheritable CSS?

Inheritance in CSS occurs when an inheritable property is not set on an element. It goes up in its parent chain to set the property value to its parent value. CSS properties such as height , width , border , margin , padding , etc. are not inherited.

Are width and height CSS properties inherited by default?

initial - Sets the height/width to its default value. inherit - The height/width will be inherited from its parent value.

How do I inherit CSS from parents?

The inherit CSS keyword causes the element to take the computed value of the property from its parent element. It can be applied to any CSS property, including the CSS shorthand property all . For inherited properties, this reinforces the default behavior, and is only needed to override another rule.


3 Answers

Try putting

width: auto;

on the button. That should fix it in this case.

like image 157
jimr Avatar answered Sep 21 '22 20:09

jimr


It is an old question but I just had the same problem with width inherit from parent as 100%. Turns out adding display property to inline-block helps.

display: inline-block;
like image 43
andr3wll Avatar answered Sep 24 '22 20:09

andr3wll


you can add "!important" to the newer css.

ex :

first{ float:right;}
second{ float:left !important;}



<div class="first second"></div>

This div should be float left

like image 2
Stéphane Avatar answered Sep 23 '22 20:09

Stéphane