I am not sure where you edit the code for my question so I put both (sorry if that confuses anyone)
In the top right hand corner there are two text boxes, but I'm not sure how to make them bigger in height. Please could you help me?
Here is the link to my site so far: http://jsfiddle.net/xiiJaMiiE/4UUgg/1/embedded/result/
#signin
{
position:absolute;
min-width:22%;
height 20%;
top:0%;
right:0%;
z-index:10;
background-color:#CCC;
border: 1px solid grey;
}
#signin input {
background-color:#FFF
}
Sorry to be a pain, but also how do I add text into it? but when the user clicks in the box is disappears?
Thanks for your help!
According to this answer, here is what it says:
In Javascript, you can manipulate DOM CSS properties, for example:
document.getElementById('textboxid').style.height="200px";
document.getElementById('textboxid').style.fontSize="14pt";
If you simply want to specify the height and font size, use CSS or style attributes, e.g.
//in your CSS file or <style> tag
#textboxid
{
height:200px;
font-size:14pt;
}
<!--in your HTML-->
<input id="textboxid" ...>
Or
<input style="height:200px;font-size:14pt;" .....>
If you want to make them a lot bigger, like for multiple lines of input, you may want to use a textarea tag instead of the input tag. This allows you to put in number of rows and columns you want on your textarea without messing with css (e.g. <textarea rows="2" cols="25"></textarea>).
Text areas are resizable by default. If you want to disable that, just use the resize css rule:
#signin textarea {
resize: none;
}
A simple solution to your question about default text that disappears when the user clicks is to use the placeholder attribute. This will work for <input> tags as well.
<textarea rows="2" cols="25" placeholder="This is the default text"></textarea>
This text will disappear when the user enters information rather than when they click, but that is common functionality for this kind of thing.
This will do it:
#signin input {
background-color:#FFF;
min-height:200px;
}
Try this:
#signin input {
background-color:#FFF;
height: 1.5em;
/* or */
line-height: 1.5em;
}
there are many options that would change the height of an input box. padding, font-size, height would all do this. different combinations of these produce taller input boxes with different styles. I suggest just changing the font-size (and font-family for looks) and add some padding to make it even taller and also more appealing. I will give you an example of all three style though:
#signin input {
font-size:20px;
}
OR
#signin input {
padding:10px;
}
OR
#signin input {
height:24px;
}
This is the combination of the three that I recommend:
#signin input {
font-size:20px;font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-weight: 300;
padding:10px;
}
.textbox {
height: 40px;
}
<div id=signin>
<input type="text" class="textbox" size="25%" height="50"/></br>
<input type="text" class="textbox" size="25%" height="50"/>
Make the font size larger and add height (or line height to the input boxes)
I would not recommend adding those size and height attributes in the HTML as that can be handled by CSS. I have made a class text-box that can be used for multiple input boxes
Related
If I have a text input immediately below a label's text, is there a way to pad some space above the input and below the label, separating the two a few pixels?
When I add padding to the top of the input box's class, it stretches the box's bottom down, while leaving its top the same distance away from the label. Padding the bottom of the label hasn't had any effect. I checked the display styles on w3 to see if it was a problem with using display:block, but that didn't look like the issue.
Sorry for the newbish question, I'm new to HTML/css. I'll keep tinkering and will appreciate any help. Thanks!
The markup:
<label for='subject'style='display:block' class='label'>
What subject do you want to follow?<br>
<input type="text" id="subject" value="meaningOfLife" style="display:block" class='form-text'><br>
</label>
And the css:
.label{
padding:5px 10px 0px 10px;
color: RGB(25,90,90);
font-size: 16;
font-weight: 8;
font-family: 'Open Sans Condensed', sans-serif;
}
Is it something you looking for?
You can apply it to one single element by ID like this:
.label #subject {
margin-top: 5px;
}
Or apply to all input elements nested inside label tag with form-text class name
.label .form-text {
margin-top: 5px;
}
To apply margin to all input="text" elements nested inside label:
.label input[type="text"] {
margin-top: 5px;
}
I have the following padding: padding:12px 24px; for input button and label for checkbox.
Font is set in body 16px Arial, all other font sizes inherited. border:0; for all elements. Why do browsers add 1px to button's height? So if label's height is 42px - button's height is 43px. This happens in Chrome and Firefox.
How to make the same height for buttons and labels?
Part of code
<input type='checkbox' name='remember' id="remember"/><label for="remember" >Remember me</label>
<input type='submit' value='Sign in' id='signin-button' /> (in the HTML form)
Try adding line-height: 17px; , sorry if you have already tried line height.
Not sure, but it probably comes down to line-heights of the fonts and how they're handled in different elements in HTML.
Try forcing a height with CSS like so:
#signin-button { height: 42px!important; border: none!important; overflow: hidden; }
I'm usually against setting exact heights for elements as a general rule, but for this case, it might just do the job and be appropriate.
Good luck.
I'm trying to style a webform in my webpage, and the form has couple of textboxes, textarea and a select dropdown. I'm having hard time styling the text area and select dropdown; textboxes are looking as expected.
For the textarea box, i used css like:
textarea{
font-size:0.9em;
color:#6da021;
border:1px solid #6da021;
width:300px; height:50px;
padding-left:10px;
font-family: tahoma, sans-serif;
}
I also tried putting an id in the textarea html and then using the above styling like:
<textarea type="text" rows="5" cols="30" name="details" id="details"></textarea>
In both ways, the border properties were applied successfully. But what did not work in both ways are - color of text inside the textarea box, and also the font looks slightly different from what is seen in the text boxes, which use the same "font-family: tahoma, sans-serif;" css.
Similarly, for the select box styling, although the border properties are coming around properly, and that the font color of the first value - the value that is shown initially, without the user having to click on the dropdown arrow - is also displayed correctly. But when the user clicks on the dropdown arrow, all the values are then shown in the default color (not the color that was specifically used for the css of select).
Is it some kind of a known problem, or am i missing out on some more styling? I see that the issue is seen across browsers (IE/firefox etc..)
Thanks!
your style is right but if u dont get reflect changes than i think ur style is replaced by some othe existing style which has a priorities
if u use firebug than check by inspecting that textarea
or if u dont know abt firebug than this is a firefox plugin, install it and check if ur stylesheet is replaced or have some other issue...
if u dont mind than reply me if more help required
Wow I am very late to see this but here is an answer to fix the font size issues
body{
font-size:15px;
font-family: tahoma, sans-serif;
}
textarea{
font-family: inherit;
font-size: inherit;
}
No need for type='text' into the textarea. You're using id='details' and name='details' which is the same thing (2 ids' reference). I suggest using a class named details for the styling and an id='content' to extract the text later, if needed.
<textarea rows="5" cols="30" class="details" id='content' value="initial-Text"></textarea>
.details {
font-family: 'Tahoma', sans-serif;
font-size: 13px;
color:#6da021;
border:1px solid #6da021;
width:300px; height:50px;
padding-left:10px;
}
I am using a submission form input field where the text is appearing about 2-5 pixels too low. This is causing letters like lower-case y, q, j, etc. to bleed below the box in Chrome and only partially appear in IE 8. To solve this problem, I would like the text to appear a few pixels higher in the input field, or make the input field a few pixels higher.
How could I do either?
Thanks in advance,
John
The code for the input field:
<div class="submissionfield"><input class="checkMax3" name="title" type="title" id="title" maxlength="80"></div>
The CSS:
.submissionfield
{
position:absolute;
width:550px;
left:30px;
top:230px;
text-align: left;
vertical-align:text-top;
margin-bottom:10px;
padding:2px;
font-family: "Times New Roman", Times, serif;
font-size: 22px;
color:#000000;
}
Set line-height to maybe 150% for input field.
You can target the input field using CSS in a few different ways:
input#title {
/* Contents here */
}
.submissionfield input {
/* Contents here */
}
.submissionfield input#title {
/* Contents here */
}
I'd stick some bottom padding on the input, or try to increase the line-height value.
I'm not seeing the problem you describe using the code you included... are there any other styles defined on your page?
I have a website design that includes text input fields that look like this:
Input Field http://img401.imageshack.us/img401/4453/picture1ts2.png
I'm wondering what the best solution for creating this input field is.
One idea I have is to always have a div around the input with a background image and all the borders disabled on the input field and specified width in pixels, such as:
<div class="borderedInput"><input type="text" /></div>
I have tried to discourage them from using this format, but they won't be discouraged, so it looks like I'm going to have to do it.
Is this best or is there another way?
--
Trial:
I tried the following:
<style type="text/css">
input.custom {
background-color: #fff;
background:url(/images/input-bkg-w173.gif) no-repeat;
width:173px;
height:28px;
padding:8px 5px 4px 5px;
border:none;
font-size:10px;
}
</style>
<input type="text" class="custom" size="12" />
but in IE (6 & 7) it does the following when you type more than the width:
Over Length http://img240.imageshack.us/img240/1417/picture2kp8.png
I'd do it this way:
<style type="text/css">
div.custom {
background:url(/images/input-bkg-w173.gif) no-repeat;
padding:8px 5px 4px 5px;
}
div.custom input {
background-color: #fff;
border:none;
font-size:10px;
}
</style>
<div class="custom"><input type="text" class="custom" size="12" /></div>
You just have to adjust the padding values so everything fits correctly.
It is - in my eyes- definitely the best solution since in any other case you're working with a whole input field. And the whole input field is - by definition - a box where users can enter text.
If you can rely on JavaScript you could wrap such div-Elements around your input fields programatically.
Edit:
With jQuery you could do it this way:
$( 'input.custom' ).wrap( '<div class="custom"></div>' );
CSS:
div.custom {
background:url(/images/input-bkg-w173.gif) no-repeat;
padding:8px 5px 4px 5px;
}
input.custom {
background-color: #fff;
border:none;
font-size:10px;
}
And your HTML:
<input class="custom" ... />
You don't need the div element, you can assign a background to the input directly.
Edit: Here is the working code. I tested it, but you'll have to adjust it for your needs. As far as I can tell, everything here is needed.
input {
background: #FFF url(test.png) no-repeat bottom right;
width: 120px;
height: 20px;
line-height:20px;
padding:0;
text-indent:3px;
margin:0;
border: none;
overflow:hidden;
}
Edit2: I'm not quite sure why I'm getting downvoted, but this method should work unless you need an image bigger than the input element itself. In that case, you should use the extra div element. However, if the image is the same size as the input, there is no need for the extra markup.
Edit3: Ok, after bobince pointed out a problem, I'm getting a little closer. This will be work in IE6&7 and it's close in FF, but I'm still working on that part.
input {
background: #FFF url(test.png) no-repeat 0px 0px;
background-attachment:fixed;
width: 120px;
height: 20px;
line-height:20px;
padding:0px;
text-indent:3px;
margin:0;
border: none;
}
body>input {
background-position:13px 16px;
}
Edit4: Ok, I think I got it this time, but it requires use of a CSS3 selector, so it won't validate as CSS 2.1.
input {
background: #FFF url(test.png) no-repeat 0px 0px;
background-attachment:fixed;
width: 120px;
height: 20px;
line-height:20px;
padding:0px;
text-indent:3px;
margin:0;
border: none;
}
body>input {
background-position:13px 16px;
}
body>input:enabled {
background-position:9px 10px;
}
body>input will target everything except for IE6, body>input:enabled will target any form elements that aren't disabled for all browsers except for IE 6, 7, & 8. However, because :enabled is a CSS3 selector, it doesn't validate as CSS2.1. I wasn't able to find an appropriate CSS2 selector that would allow me to separate IE7 from the other browsers. If not validating (yet, until the validator switches to CSS3) is a problem for you, then I think your only option is the extra div element.
Have you evaluated using background image like this:
<style type="text/css">
input{
background-color: #AAAAAA;
background-image: url('http://mysite.com/input.gif');
border: 0px;
font-family: verdana;
font-size: 10px;
color: #0000FF;
}
I have done this a few times. I have the background image inside a div and use css to position the input field accordingly.
Have a peek at the following site I created that used this technique and use the code: http://www.ukoffer.com/ (Right hand side Newsletter)
AFAIK, the background scrolling problem can be solved either in Firefox and friends, OR Internet Exploder; but not make everyone happy at once.
I would normally have said to style the input directly, but now that I think of it that div example doesn't sound too bad and should take care of your background image scrolling problem.
In that case you'd set a div as position:relative, and put the input inside it with proper padding and width (or 100% width if padding is 0), background transparent, and put an image on the div.
okoman has gotten the CSS aspect correct. May I suggest using a <label> to improve the semantic structure of the markup?
<label id="for-field-name" for="field-name">
<span class="label-title">Field Name <em class="required">*</em></span>
<input id="field-name" name="field-name" type="text" class="text-input" />
</label>
<style type="text/css">
label, span.label-title { display: block; }
</style>
Not only is this more accessible, but it provides numerous hooks that you can use for any type of DOM manipulation, validation or field-specific styling in the future.
Edit: If you don't want the label title displayed for some reason, you can give it a class of 'accessibility' and set the class to display: none; in the CSS. This will allow screen readers to understand the input but hide it from regular users.
The easiest way to get rid of the overflow without JavaScript is simple:
Create a 3 spans, and set their heights to the height of the
image.
Cut the image into 3 parts, ensuring you cut the image such that
the left and right round parts will be on the 1st and 3rd images
respectively.
Set the background of the 1st span to the image
with the left border, and set it to no-repeat.
Set the background
of the third span to the image with the right border and set it to
no-repeat.
Put the input inside the middle span, remembering to
set its height to the height of the spans, and its background to the
2nd image, and repeat-x only.
That will ensure that the input
will seem to expand horizontally once the input is being filled. No
overlapping, and no JS needed.
HTML
Assuming the image height is 60px, the width of the first and third span is 30px,
<span id="first">nbsp;</span><br />
<span id="second"><input type="text" /></span><br />
<span id="third">nbsp;</span>
CSS
span#first{background:url('firstimage') no-repeat; height:60px; width:30px;}
span#third{background:url('thirdimage') no-repeat; height:60px; width:30px;}
span#second input{background:url('second image') repeat-x; height:60px;}
That should resolve your issue.