How to fix input paddig in HTML5 - css

I have a problem with padding in HTML5. I'm using this code:
input[type="password"] {
border: 1px solid #CECECE;
border-radius: 0 0 3px 3px;
padding: 7px;
font-size: 1em;
outline: none;
width: 100%;
margin: 0px;}
I use inputs in div, which has padding 10px.
And when I'm testing code the width of input is not right, look at this pic:
How to solve this problem? I want to have padding 10px in any window size.

Add this CSS :
input {
-moz-box-sizing:border-box;
-webkit-box-sizing: border-box;
box-sizing:border-box;
}
This property will include padding and border to the width/height of inputs so they won't overflow anymore.

Use:
box-sizing:border-box;
-moz-box-sizing:border-box;
in your css file.
input[type="password"] {
border: 1px solid #CECECE;
border-radius: 0 0 3px 3px;
padding: 7px;
font-size: 1em;
outline: none;
width: 100%;
margin: 0px;
box-sizing: border-box;
-moz-box-sizing: border-box;
}

/* apply a natural box layout model to all elements */
*, *:before, *:after {
-moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;
}
http://fiddle.jshell.net/yTM9U/2/

You need to set the CSS style margin-right for the input.
input {
margin-right: 10px;
}
Padding is a cushioning/space inside the element. To push an element away from
surrounding elements internal cushioning/padding-space cannot help. Margin needs
to be set for those purposes...
But in your case, r/l to the form width, inputs are already very wide (100%). So, you need to decrease the width of the inputs. Try
input {
width: 90%;
max-width: 90%;
}

Related

Entered text causing textarea to expand outside of div after form submit

I have a form that is driving me nuts. The form contains several textareas as input fields. When copying and pasting or just typing the data into the textarea everything is fine. However, when I submit the form and it re-displays, the textarea has now expanded, outside of its container div, to accommodate any text that has no spaces in it and overflows the width. Should it not wrap like it did when first entered? And if so, how do I get it to stop expanding the textarea?
Examples:
Before from submit:
After form submit:
#incexfrm {
width: 675px;
background-color: #d9d9d9;
border: 2px solid #000;
}
.category textarea {
height: 100%;
width: 99%;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
The #incexfrm id is the CSS for the container. The .category class contains the CSS for the various textareas on the form.
Any help would be appreciated. Thank you!
As per your question, I have suggested you to use the following code-
Here your textarea must be in category class
#incexfrm {
width: 675px;
background-color: #d9d9d9;
border: 2px solid black;
}
.category {
width: 100%;
}
.category textarea {
height: 100%;
width: 99%;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}

Ribbon across container in Bootstrap 3 not working

I'm not quite sure what I'm doing wrong here.
I'm trying to apply a ribbon across a container using the example on this site:
http://www.andreapinchi.it/css3-ribbon-effect/
I've created a mock-up of the problem here:
http://jsbin.com/rebexatijizi/1/edit
Doesn't look much like the other. :(
*NOTE: JSBIN link updated above to show current status.
DEMO: http://jsbin.com/tibaqenawena/4/edit
CSS:
.ribbon, .ribbon:before, .ribbon:after {box-sizing:content-box;}
You can also just adjust the math in your css to include padding and borders. DEMO: http://jsbin.com/dupac/1/edit
div.both_ribbon::before{
display: block;
width: 10px;
height: 0px;
position: absolute;
bottom: -10px;
left: -2px;
content: "";
border-bottom: 10px solid transparent;
border-right: 10px solid rgb(0, 80, 116);
}
div.both_ribbon::after{
display: block;
width: 10px;
height: 0px;
position: absolute;
bottom: -10px;
right: -2px;
content: "";
border-bottom: 10px solid transparent;
border-left: 10px solid rgb(0, 80, 116);
}
Also, your css is messed up and it still is, you have a enclosed a style within another style.
Your box-sizing properties seem to be messing everything up. In bootstrap.css remove the box-sizing rules. Also, take the padding off of your container (you can add another child element within your container that has padding instead). Here is the code you should remove:
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
:before, :after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}

Block Borders Using Bootstrap

I have a sidebar block using bootstrap with two image blocks, one on top of the other, and my client wants a glowing red border around the blocks. I have a black background and the border for the glow. Here is the problem, when I resize the browser to a tablet size, the black background and border are wider than the image and the image is not centered. I want the border and glow to be 10px around the image and centered in the screen, not to the left. If I use a transparent background the image is to the left and the red border spans the whole screen and once again looks bad. Here are two screenshots:
I want the images to resize and be next to each other like other responsive templates with the glow and nothing I try is working. This is all probably pretty simple but I am lost. I am learning but this is driving me crazy. I have applied some additional css through c5 to give a glow to the images in the block. This is the code that comes up when I use Chrome dev tools:
element.style { }
#blockStyle167Sidebar40 {
background-repeat: no-repeat;
background-color: #000000;
-webkit-box-shadow: 0 0 6px 4px rgba(255,0,0,.7);
box-shadow: 0 0 6px 4px rgba(255,0,0,.7);
padding: 10px;
}
.pic {
border: 1px solid #000000;
height: 245px;
width: 370px;
overflow: hidden;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 10px;
margin-left: 0px;
}
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
}
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
}
user agent stylesheetdiv {
display: block;
}
Inherited from div#sidebar-wrap.span4.sidebar-wrap.sidebar.color-content.pad
#main-content .color-content {
color: #FFFFFF;
}
Inherited from div.row-fluid.has-sidebar
#page .row-fluid {
color: #ffffff;
I am sorry this is so long but my site is in maintenance mode and I don't know how to link the page. I could give someone acces so the can look at it.
Thanks for any help.
Essentially what you need to do is create a transparent border of 10px with a red box shadow.
img {
border: 10px solid transparent;
box-shadow: 0px 0px 15px 0px rgba(255,0,0,1);
}
Then set each of the images to the width % you want.
See this jsfiddle http://jsfiddle.net/TZh2Y/

CSS box-sizing messing with form heights

I've uploaded this question a while ago but it ended up giving me the tumbleweed badge so I'm trying again.
I'm going through Michael Hartl's railstutorial right now and I've encountered a problem where box-sizing property is interfering with form heights as shown in pictures below.
#mixin box_sizing {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
input, textarea, select, .uneditable-input {
border: 1px solid #bbb;
width: 100%;
height: auto;
margin-bottom: 15px;
#include box_sizing; <--- this line here is causing issues
}
(box-sizing property in effect)
(box-sizing property not in effect)
Notice how much smaller forms are when box-sizing property is in effect? You can't really view full letters because the height is so low. I've tried to change the height property under input, textarea, ..etc. but it seems like my code is being overridden by Bootstrap. If you have any idea how to make the forms bigger (greater height) I would really appreciate it.
box-sizing: border-box changes the box model so padding is taken out from the height, rather than adding to it.
So this block:
div {
box-sizing: content-box; // default
height: 2em;
padding: .25em;
}
Will be 2.5em tall, and this block:
div {
box-sizing: border-box;
height: 2em;
padding: .25em;
}
will be 2em tall, with .5em of spacing partitioned for the padding.
The other issue is how bootstrap defines the height of inputs:
input[type="text"], ...other selectors..,
.uneditable-input {
display: inline-block;
height: 20px;
...
}
The reason defining a height wasn't working, is because input[type="text"] is more specific than input, and therefore the bootstrap declaration was overriding yours.
To solve the problem you are having with the inputs, define a height and use a more specific selector:
input[type="text"], textarea, select, .uneditable-input {
border: 1px solid #bbb;
width: 100%;
height: 2em;
margin-bottom: 15px;
#include box_sizing;
}
Demo

Michael Hartl Rails Tutorial - CSS not rendering properly

I already finished the tutorial but I'm having a slight issue with the CSS rendering since section 7 where you make the signup form. This is what I'm getting:
And this is what it's supposed to look like:
And this is the relevant CSS:
#mixin box_sizing {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
input, textarea, select, .uneditable-input {
border: 1px solid #bbb;
width: 100%;
padding: 10px;
height: auto;
margin-bottom: 15px;
#include box_sizing;
}
Was wondering if anyone else had the same issue?
The difference is probably with the default height of an input in Chrome vs FireFox (Hartl's browser).
The CSS declaration height:auto; lets the browser calculate the default height.
I had the same issue with Chrome, and although I don't know if it's a good solution, I got the expected results by getting rid of the #include box_sizing; comment:
input, textarea, select, .uneditable-input {
border: 1px solid #bbb;
width: 100%;
padding: 10px;
height: auto;
margin-bottom: 15px;
// #include box_sizing;
}
Based upon the Handy Sass Mixins by Jake Bresnehan at http://web-design-weekly.com/blog/2013/05/12/handy-sass-mixins and the section on Box Sizing, I was able to change the mixin block and the "include" line and get things working with the following situations:
#mixin box_sizing {
-moz-box-sizing: $box-model;
-webkit-box-sizing: $box-model;
box-sizing: $box-model;
}
.debug_dump {
clear: both;
float: left;
width: 100%;
margin-top: 45px;
#include box_sizing(border-box);
}
input, textarea, select, .uneditable-input {
border: 1px solid #bbb;
width: 100%;
margin-bottom: 15px;
#include box_sizing(border-box);
}
input {
height: auto !important;
}
which is also referencing the Michael Hartl, Ruby on Rails Tutorial, Ch. 7 at http://ruby.railstutorial.org/chapters/sign-up#top

Resources