I have a problem using a given CSS file I don't want to change. In this file there is a format for inputs:
input {
display:inline-block;
width:60%;
}
Now I want to use an additional CSS file and change this formatting to a normal block element width full width:
input {
display:block !important;
width:auto !important;
}
Unfortunately, this doesn't work. Unlike normal block elements, the input does not take all the available horizontal space with this setting. It is only as long as it would be as inline element. Additionally, I cannot use width:100%; due to padding, borders and margin. In my desperation I already tried something like width:none;, but I couldn't find a way to reset the width to a block element's default value.
I really hope that somebody can help me. Thank you in advance.
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.
The default width of a block-level element is the length of the page.
CSS tip: To reset a min-height or min-width declaration, set it to "0", not "auto". For max-height/width, the initial value is "none". Also see nimbupani.com/safe-css-defau… Just used this to solve resetting width on #mobileFirst breakpoints!
Answer: Use the CSS all Property You can simply use the CSS all property with the value revert to remove the additional author-defined CSS styling for an element (i.e. reset to browser's default CSS styling).
You must use width: 100%
, so my answer shows how to fix the problems you're having with it.
https://developer.mozilla.org/en/CSS/box-sizing
input {
width: 100%;
margin: 0;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
If margin
is required, then wrap the input
in another element and apply the margin
to that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With