I have attempted to use this CSS to set the width of my form elements:
input[type="text"], textarea { width:250px; }
If you look at this Firefox screenshot you'll see that the fields are not the same width. I get a similar effect in Safari.
alt text http://screamingv.com/ss.png
Are there any workarounds?
UPDATE: Thanks for the info so far. I've now made sure padding/margin/border on both elements are set the same. I was still having the problem. The original CSS I posted was simplified... I was also setting the height of the textarea to 200px. When I remove the height styling, the widths match. Weird. That makes no sense.
Browser bug?
Try removing padding and borders. Or try making them the same for both elements
input[type="text"],
textarea {
width:250px;
padding: 3px;
border: none;
}
Or:
input[type="text"],
textarea {
width:250px;
padding: 0;
border: 1px solid #ccc;
}
INPUT and TEXTAREA elements often have some padding applied by the browser (varies by browser) and this can make things appear effectively wider than the assigned width.
UPDATE: also box-sizing: border-box; is a handy way to set widths that that padding and border will eat into rather than add onto. See: http://www.paulirish.com/2012/box-sizing-border-box-ftw/
This answer is three years late, but I'm posting it here just in case anyone else is trying to set the width in em's and not pixels and comes across this post (as I just did). Make sure the font-size is the same,
e.g.
input, textarea {
font-size:12px;
width:20em;
padding:0;
margin:0
}
otherwise the textarea may be a different size (true on FF12).
Try border:0; or border: 1px solid #000;
This is probably caused by different default margins on the <input> and <textarea> elements. Try using something like this.
input[type="text"], textarea {
padding: 0;
margin: 0;
width:250px;
}
I was struggling with this kind of problem too, and this question was the first result of my googling. What finally worked for me was setting box-sizing: content-box for the textarea - Drupal 7 defaults this to border-box which causes the padding and border width to be subtracted from the size of the textarea.
Set width 100% and then use max-width:
textarea {
width:100%;
max-width:250px;
}
// removed margin and padding, you can add it if you want.
Maybe you have a user specific css overlay defined somewhere in your browser, because i just tested it and it works as expected: http://jsbin.com/exase/edit
(Tested on windows. Maybe Apple native widgets have some quirk?)
you may use:
input[type="text"], textarea {
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
Related
I have some issue which only encounters my iPad Pro 12.9, but not on phones or desktops.
🐞 on : Safari + Chrome + Firefox
input[type=text], input[type=email], input[type=time] {
color: white;
background-color: black;
font-size: 1em;
width: 100%;
border: solid 1px white;
border-radius: 5px;
margin: 10px;
padding: 10px;
}
How do I make my inputs padding look nice on all browsers all devices?
Firstly you need to make sure your inputs aren't being over-ridden from another declaration which often causes the problem you have here, particularly in relation to the line-height and font-size properties. Set your line-height value to line-height: normal on your input elements. Using the input[] selector has a low specificity in the CSS cascade, hence why it could be being over-ridden.
If the above values aren't being over-ridden from a different part of your stylesheet you can use box-sizing:border-box, line-height: normal on your input elements. You'll most likely need to increase the padding value slightly to get the aesthetic look you require.
How about to use all: unset;
To be honest I found out about it just yesterday and not used it yet, but it seems to be widely supported.
Here is a small demo. Though, I used sass.
Screenshot from iPad Pro:
Screenshot from Chrome (on Linux):
You don't really need padding top and bottom within an input, so you can remove it, just use padding: 0 10px
If some browser do not vertically centres the text, you can equal the line-height with the height and that should be fine.
also apply a box-sizing: border-box; rule will probably avoid differences between browsers on how do they render paddings.
Buttons are large and going over the card width
This should be easy, but I'm having a bit of tough time customizing the buttons inside the cards. I want to remove all the padding, so that the black border nicely encompasses the icon without any extra space in the left/right-hand sides. I've tried adding custom css and !important and directly overriding the div.btn__content, but those don't work. Any ideas to do this as simply as possible?
Reproduction Link
The issue is the min-width of the .btn class. Setting that to 0 will allow the button to be smaller than 88px. You should also just set the padding of the .btn__content to 0.
div.btn__content {
padding: 0;
}
div.card__actions .btn {
min-width: 0;
}
Here's an updated codepen.
For newer versions of Vuetify (1.2.4 and above) you need to use this:
/* turn off min-width for all buttons */
.v-btn {
min-width: 0;
}
You need to change min-width of .btn class and set padding-left: 16px of .btn-content.
Here is an example:
https://codepen.io/anon/pen/zPEyLB
You might have to use ::v-deep
::v-deep .v-btn {
padding-left: 12px;
padding-right: 12px;
}
I've a Button with the following super simple css:
button {
background: #005eb8;
border: 0;
padding: 0;
color: white;
line-height: 50px;
}
"line-hight" is set to 50px. But the button is (in Firefox) 52px - I expected it to be 50. Is there any reason for that? In chrome the height is 50 as expected...
Code at JSBIN:
http://jsbin.com/jagiviyima/9?html,output
button::-moz-focus-inner,
input[type="reset"]::-moz-focus-inner,
input[type="button"]::-moz-focus-inner,
input[type="submit"]::-moz-focus-inner {
border: none;
padding:0;
}
Add such css rule.
You ask - is there some reason for that - I believe it is. I don't have Firefox at hand now, but you are using button html element and buttons typically have some default css rules applied to them across the browsers (these are obviously browser specific). My guess is FF is adding some default padding, margin, border or something of that kind to your own defined style. Try setting these to 0 explicitly.
A bit of googling yielded this SO answer which exlains the issue in a more detail, proposed resolution is:
button::-moz-focus-inner,
input[type="button"]::-moz-focus-inner {
padding: 0 !important;
border: 0 none !important;
}
I am new to CSS. I am observing a strange CSS behaviour where an element has the below CSS property
.container .header{
color: #FFFFFF;
font-size: 2em;
font-weight: bold;
padding: 5px;
position: relative;
text-align: center;
top: 21%;
}
When the page loads on Mozilla and chrome, the top property is not applied but inspecting the firebug shows the property. When I edit in firebug just by 1px, the elements gets properly aligned and even if I set the top value to 21% after that, the position is correct. Only on load the CSS property is not applied. Can you please let me know where I am going wrong?
It's because you are calculating the top value in percentages and to make that happen, you need a declared height for it's parent i.e. container.
.container, body, html {
height:100%;
}
Add the rule above and see it working. FIDDLE HERE
NOTE - body and html also need their height declared(either in percentages or pixels) too as container's parent is body and like so.
I know exactly what it is now. Its your style class names themselves. After much testing I have discovered:
.container, .header {
color:#ffffff;
font-size:2em;
font-weight:bold;
padding:5px;
position:absolute;
text-align:center;
top:21%;
}
Notice what's after the .container? A COMMA. You need a Comma after every class name that inherits those same attributes! Hope this helped!
I have a bottom border of:
div#footer-case{
border-top:solid black 1px;
width:100%;
margin:8% auto;
}
but the border does not span the whole page, instead there are about 5px on the left and the right.
i set the width to 100%, but i do not know why it will not fully go left to right
If you don't want to edit the default browser margin of the body, try this:
div#footer-case
{
border-top:solid black 1px;
width:103%;
margin-left:-10px;
}
Tested with FF 8, Chrome 16, and Safari 5 on OS X Lion.
Browsers have default margin on the viewport, usually set in modern browsers on the body element. Try resetting it with this:
body {margin:0;padding:0;}
It may help in ongoing development efforts to implement a nice CSS reset such as this one:
http://meyerweb.com/eric/tools/css/reset/
Or even just studying default user agent stylesheets and how resets work would help understand all the fun little challenges we have to confront to get CSS to bend to our wills and behave consistently. Here's a nice article on the subject:
http://meiert.com/en/blog/20070922/user-agent-style-sheets/
body {
margin: 0px;
padding: 0px;
}
.footer
{ height:125px; width:103; position:relative; background-color:#333; color:#FFF; margin-left:-10px;}