I'm a CSS/HTML novice and I haven't really found how to do this by searching. I have a simple login page where a person enters in a username and password. The page has a large background image. I want to create a rounded box that the two text fields (username and password) and the submit button goes into and sits on top of to further separate form the background image. Here is the main part of the html file, I just want to know what should I put into the container section of the CSS file to get a rounded white box .
<div class="container">
<form class="form-signin" role="form" name='f'
action='${pageContext.request.contextPath}/j_spring_security_check' method='POST'>
<h2 class="form-signin-heading">Please sign in</h2>
<input type='text' name='j_username' class="form-control" placeholder="Username"
required autofocus>
<input type='password' name='j_password' class="form-control"
placeholder="Password" required>
<div class="checkbox">
<label>
<input type="checkbox" value="remember-me"> Remember me
</label>
</div>
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
</form>
As far as a box goes, you can just create a div for that(as I see you've done: .container). To round the corners, you'll want to use the CSS property border-radius:
HTML:
<div id="example1">Hello!</div>
CSS:
#example1 {
width: 100px;
background: green;
border-radius: 15px;
margin: 0 auto;
text-align: center;
}
JSFiddle Example
It appears you have a bootstrap example. First, you need to use bootstrap (http://getbootstrap.com) then add a class that suits you best to container. I recommend the classes "well", "thumbnail", and "jumbotron". Visit the CSS section on the bootstrap site to see these rendered. If you don't want to use bootstrap, just copy the CSS code and apply it to your example.
Related
I'm using this CSS file:
https://ssl.gstatic.com/docs/script/css/add-ons1.css
Here's the code for the form I'm using:
<form id="myform">
<div class="block form-group">
<input type='text' required="required"/ style="width:300px;">
</div>
<div class="block">
<button type="submit" class="button">Submit</button>
</div>
</form>
I've tried to figure out how to change the button color from blue to orange, but I'm getting incredibly confused with all of the CSS lines. I tried to force some css styling into the button, but I think I'm messing up somewhere since all of my changes makes the button just look weird but doesn't actually change the color.
I inspected element and tried to make changes to various lines and I tried copying the CSS to my own website thinking it might be a caching issue, but whatever I try, I can't get the button to change from blue to orange, lol.
Don't know why you should be getting 'confused with lines of css'
why not add a class
.orange{
background: orange;
}
to the end of your css file,
and add orange to your html button code
<form id="myform">
<div class="block form-group">
<input type='text' required="required"/ style="width:300px;">
</div>
<div class="block">
<button type="submit" class="button orange">Submit</button>
</div>
</form>
let me know
I have this registration form I am setting up and I've set the page's background to grey. I want the area in the center, where you're supposed to fill in the info, to be white. How should I do this?
I've included a picture of how the site looks now, the white part should cover the text and all the boxes.
My css code for background:
body{
background-color:#D2D7D3;
background-size:1500px 1000px;
z-index:0
position:absolute;
}
This is something you could do, wrap your form contents in a div and style the div around it.
This will create the white part you want behind the form.
Example Form
<div class="form-container">
<form>
<label for="email"> Email </label>
<input type="text" name="email"></input>
<label for="password"> Password </label>
<input type="text" name="password"></input>
<button type="submit"> Register </button>
</form>
</div>
In your CSS
.form-container {
width: 300px;
height: 300px;
background-color: #fff;
}
I have the following HTML:
<form class="form-inline" role="form">
<div class="form-group">
<input class="form-control" type="text" placeholder="Your comments" />
</div>
<div class="form-group">
<button class="btn btn-default">Add</button>
</div>
</form>
The issue I am facing is that these two elements aren't taking the entire line (they aren't touching). See here:
Why is this the case?
Here is a fiddle show casing the problem: https://jsfiddle.net/nirchernia/pyfetd4p/
A couple of things:
form-group is display:block.
put both the input and button tag inside the same form-group
The form-control is a display:block as well. Use CSS to force it to display:inline-block and shorten the width (it was 100%).
jsfiddle: https://jsfiddle.net/b6x12fc8/
<div class="form-group">
<input class="form-control" type="text" placeholder="Your comments" />
<button class="btn btn-default">Add</button>
</div>
.form-inline .form-control { width:75%; display:inline-block;}
Give following css. Because currently it will taking width:auto; So, it will take default width of input field.
To make it touch with button. Give 100% and there is padding given so, it will increase more width and overlap the button. So, remove padding but padding:0
.form-inline .form-control {
padding: 0;
width: 100%;
}
https://jsfiddle.net/pyfetd4p/1/
To make side by side in small screen use following css;
.form-inline {
display: flex;
}
Fiddle link
I'm putting together a simple form to deposit a set amount of money. The form has 4 radio buttons.
<form action="deposit.php" method="post">
<fieldset>
<div class="form-group">
<input type="radio" name="deposit" value="100"> $100
<br>
<input type="radio" name="deposit" value="250"> $250
<br>
<input type="radio" name="deposit" value="500"> $500
<br>
<input type="radio" name="deposit" value="1000"> $1,000
<br>
</div>
<div class="form-group">
<button type="submit" class="btn btn-default">Deposit</button>
</div>
</fieldset>
</form>
Here is the output:
You can see that the last radio button is not vertically aligned. I realize that there are 2 extra characters in the text after the button. I'm no CSS wizard and haven't really found the answer to making these buttons straight. Any ideas?
EDIT: CSS code here:
.container {
/* center contents */
margin-left: auto;
margin-right: auto;
text-align: center;
}
input[type='radio'] {
width: 20px;
}
The form is in the container
In your CSS file or within your HTML code you are using the "align centre" setting. Thats why is not aligned.
This is the output of your above code with the align centre setting:
And this is the output of your code without the align centre setting:
Somewhere in your code you are setting the below div class to align centre.
// Removing the align setting will solve the issue. If its not in-line CSS then check you external CSS file.
<div class="form-group" align="center">
Hope this helps.
Why not use tables to make the buttons align (its easier with dreamweaver as your editing tool)
Bootply codes can be seen here => http://www.bootply.com/QpvisrtAJR
I want the input box to be longer, however, the width:100% doesn't work for it.. And I don't want to use width: xxxpx or size=xxx to make it longer because it will be un-responsive in different resolution..
Does anyone have ideas about this?
Your input rule isn't actually being applied. It is not specific enough so is being overwritten by a default bootstrap rule. Try this instead:
.form-inline button.form-control,
#contain_word
{
display: block;
width: 100%;
}
http://www.bootply.com/Qh2VwydnHx
Also you have a an erroneous character in your html where you give the input field an id. Should be:
<input type="email" class="form-control" id="contain_word">
Not:
<input type="email" class="form-control" id="contain_word`">
You can use the calc() method to have the input field 100% in width but still float left to the label.
Updated Bootply: http://www.bootply.com/2K3ZIWsuWy
Calc() is compatible with most browsers except Opera Mini. For Blackberry you still need -webkit.
Check out the compatibility table here: http://caniuse.com/calc
You can add your class with a specified width
or override existing styles, but it is better to create your own style file
http://www.bootply.com/QpvisrtAJR#
div class="row">
<form class="form-inline" role="form">
<div class="form-group col-sm-6 no-padding">
<label for="contain_word`">Containing word(s): </label>
<input class="form-control test" id="contain_word`" type="email">
</div>
<div class="col-sm-2">
<button class="btn btn-primary form-control">Search</button>
</div>
<div class="col-sm-2">
<button class="btn btn-primary form-control">Clear</button>
</div>
</form>
</div>