Trying to style a button but wont work - html

I'm in the process of styling a profile page for my website.
I want to style the buttons for New Post, Contact Me and Log Out on the Profile Page the same as the Log In button on the Login Box which looks like this:
The code and CSS for this one is like this
Code:
input[type=submit] {
width: 100%;
background: #28343b;
color: #ffffff;
border: 1px solid #000;
padding: 10px;
font-size: 20px;
cursor: pointer;
border-radius: 5px;
margin-bottom: 1px;
}
<form action="" method="post">
<div id="loginbox">
<label>Username:</label>
<input type="text" name="username" id="name" placeholder="Username" />
<br />
<br />
<label>Password:</label>
<input type="password" name="password" id="password" placeholder="**********" />
<br/>
<br />
<input type="submit" value=" Login " name="submit" />
<br />
<span></span>
</form>
</div>
I have indicated below which are the items I would like to style in this same button format.
What would I need to put in the CSS (and any changes to HTML) to style those items the same?
<div id="login">
<h2>Welcome:</h2>
<hr/>
<form action="" method="post">
<div id="loginbox">
<div id="submit"> Contact Me </div> <----- THIS ONE
<div id="newpost"> Make a New Post </div> <----- THIS ONE
<div id="logout">Log Out</div> <----- THIS ONE
<span></span>
</form>
</div>
It currently looks like this.

Use this css code to style your Log out link like Login button.
#logout{
width: 100%;
background: #28343b;
border: 1px solid #000;
padding: 10px;
font-size:20px;
cursor:pointer;
border-radius: 5px;
margin-bottom: 1px;
text-align:center;
font-weight:bold;
}
#logout a { /*all font customizations goes here*/
color: #fff;
text-decoration: none;
}
Check results here

I've changed a few little things around:
I've placed your id's onto your a elements, instead of the parent divs
I've added a little bit of extra css to ensure it overrides the default a tag stylings (i.e. underlining)
I've used the same css for your elements (using a comma to separate them)
I've also have styled your form similarly to your image, although you may want to alter this to be more precise.
Added a very simple hover effect
This leave your with this:
input[type=submit],
#submit,
#newpost,
#logout {
width: 96%;
background: #28343b;
color: #ffffff;
border: 1px solid #000;
padding: 10px;
font-size: 20px;
cursor: pointer;
border-radius: 5px;
margin-bottom: 1px;
text-decoration: none;
display: block;
font-family: arial;
transition: all 0.5s;
}
#login {
background-color: #109cca;
padding: 5px;
border: 2px solid gray;
border-radius: 10px;
text-align: center;
}
input[type=submit]:hover,
#submit:hover,
#newpost:hover,
#logout:hover {
color: #109cca;
}
<div id="login">
<h2>Welcome:</h2>
<hr/>
<form action="" method="post">
<div id="loginbox">
<div> <a id="submit" href="cms/contact.php"> Contact Me </a>
</div>
<div> <a id="newpost" href="cms/index.php"> Make a New Post </a>
</div>
<div><a id="logout" href="logout.php">Log Out</a>
</div>
</div>
</form>

Try this:
#submit,#newpost,#logout {
width: calc(100% - 40px);
background: #28343b;
color: #ffffff;
border: 1px solid #000;
padding: 10px;
font-size: 20px;
cursor: pointer;
border-radius: 5px;
margin-bottom: 1px;
text-align:center;
}
a{
color:white;
text-decoration:none;
}
<div id="login">
<h2>Welcome:</h2>
<hr/>
<form action="" method="post">
<div id="loginbox">
<div id="submit"> Contact Me
</div>
<div id="newpost"> Make a New Post
</div>
<div id="logout">Log Out
</div>
<span></span>
</div>

Like ṧнʊß mentioned, the #submit, #newpost, and #logout inputs are not inputs - they're divs, so they're not going to use the "input type=submit" CSS rule.
If you want to change these into inputs that would inherit the CSS rules, then you could convert them like so:
<input id="submit" src="cms/contact.php" value="Contact Me" type="submit"/>
It would probably make more sense, however, to change the CSS rule itself to some kind of class:
.fancyButton {
width: 100%;
background: #28343b;
border: 1px solid #000;
padding: 10px;
font-size:20px;
cursor:pointer;
border-radius: 5px;
margin-bottom: 1px;
text-align:center;
font-weight:bold;
}
And to give each of these <input> divs this class:
<input id="logout" class="fancyButton">

input {
width: calc(100% - 40px);
background: #28343b;
color: #ffffff;
border: 1px solid #000;
padding: 10px;
font-size: 20px;
cursor: pointer;
border-radius: 5px;
margin-bottom: 1px;
padding: 10px;
}
input[type=submit] {
width: calc(100% - 20px);
}
<form action="" method="post">
<div id="loginbox">
<label>Username:</label>
<input type="text" name="username" id="name" placeholder="Username" />
<br />
<br />
<label>Password:</label>
<input type="password" name="password" id="password" placeholder="**********" />
<br/>
<br />
<label></label>
<input type="submit" value=" Login " name="submit" />
<br />
<span></span>
</div>
</form>

Related

position the text in the required place

HTML
<div class="form">
<!-- USERNAME BOX-->
<label for="username"><b>Username or email address</b></label><br>
<input type="text" name="username" value=""><br>
<!-- PASSWORD BOX -->
<label for="password">
Password
Forgot password?
</label><br>
<input type="password" name="password" value=""><br>
<!-- SIGN IN BUTTON -->
<input type="button" name="button" value="Sign in">
</div>
CSS
.form{
background: white;
border: 1px solid #aaa;
padding: 15px;
border-radius: 5px;
}
label{
font-size: 12px;
font-weight: 600;
text-align: left;
}
input{
margin-top: 5px;
margin-bottom: 10px;
width: 300px;
height: 25px;
border-radius: 5px;
border: 1px solid #aaa;
text-indent: 5px;
box-shadow: inset 0 0 1px #000;
outline-color: dodgerblue;
}
input[type="button"]{
background: green;
color: white;
font-weight: 600;
height: 30px;
border: darkgreen;
}
label a{
float: right;
transform: translateY(3px);
text-decoration: none;
}
I want Forgot password? to end exactly where the input field ended. I have tried to do this but i couldn't. Plese help me to fix this. It shifted towards right from the required position.
You should add the following css for label so that label will be same width as input, and its Forgot password? aligns with input field.
width: 300px;
display: inline-block;
.form{
background: white;
border: 1px solid #aaa;
padding: 15px;
border-radius: 5px;
}
label{
font-size: 12px;
font-weight: 600;
text-align: left;
width: 300px;
display: inline-block;
}
input{
margin-top: 5px;
margin-bottom: 10px;
width: 300px;
height: 25px;
border-radius: 5px;
border: 1px solid #aaa;
text-indent: 5px;
box-shadow: inset 0 0 1px #000;
outline-color: dodgerblue;
}
input[type="button"]{
background: green;
color: white;
font-weight: 600;
height: 30px;
border: darkgreen;
}
label a{
float: right;
/* transform: translateY(3px); */
text-decoration: none;
}
<div class="form">
<!-- USERNAME BOX-->
<label for="username"><b>Username or email address</b></label><br>
<input type="text" name="username" value=""><br>
<!-- PASSWORD BOX -->
<label for="password">
Password
Forgot password?
</label><br>
<input type="password" name="password" value=""><br>
<!-- SIGN IN BUTTON -->
<input type="button" name="button" value="Sign in">
</div>
I think you positioned you forgot password on the wrong place.
<div class="form">
<!-- USERNAME BOX-->
<label for="username"><b>Username or email address</b></label><br>
<input type="text" name="username" value=""><br>
<!-- PASSWORD BOX -->
<label for="password">
Password
</label><br>
<input type="password" name="password" value="">Forgot password?
<br>
<!-- SIGN IN BUTTON -->
<input type="button" name="button" value="Sign in">
</div>
Firstly, you need to remove the <br>s after the labels:
<div class="form">
<!-- USERNAME BOX-->
<label for="username"><b>Username or email address</b></label>
<input type="text" name="username" value=""><br>
<!-- PASSWORD BOX -->
<label for="password">
Password
Forgot password?
</label>
<input type="password" name="password" value=""><br>
<!-- SIGN IN BUTTON -->
<input type="button" name="button" value="Sign in">
</div>
Then, you need to add display: block; and width: 310px; to the label:
label {
font-size: 12px;
font-weight: 600;
text-align: left;
display: block;
width: 310px;
}

Moving text in input

I'm having trouble to move text inside input. If i add margins or paddings it moves or scales the input. I want to move "Username" 10px away from left side.
.log_inp input[type="username"] {
top: 80px;
height: 28px;
width: 234px;
border: solid 1px #e4e4e4;
font-family: OpenSans-Italic;
color: #9a9a9a;
font-size: 13px;
}
input {
padding: 0px;
}
<div class="log_inp">
<form action="#">
<input type="username" name="Username" placeholder="Vārds...">
<br>
<input type="password" name="Password" placeholder="Parole...">
<br>
<input type="submit" value="Ienākt">
</form>
</div>
If you want to only move the placeholders over, use vendor prefix CSS properties:
::-webkit-input-placeholder {
padding-left: 10px;
}
::-moz-placeholder {
padding-left: 10px;
}
:-ms-input-placeholder {
padding-left: 10px;
}
<div class="log_inp">
<form action="#">
<input type="username" name="Username" placeholder="Vārds...">
<br>
<input type="password" name="Password" placeholder="Parole...">
<br>
<input type="submit" value="Ienākt">
</form>
</div>
If you want to change the padding and not have it influence the total size of the input, set box-sizing to border-box.
In the following example, the two inputs are the same size, but I have given the username one a left padding.
.log_inp input {
top: 80px;
height: 28px;
width: 234px;
border: solid 1px #e4e4e4;
font-family: OpenSans-Italic;
color: #9a9a9a;
font-size: 13px;
padding: 0px;
box-sizing: border-box;
}
input[type="username"] {
padding-left:10px;
}
<div class="log_inp">
<form action="#">
<input type="username" name="Username" placeholder="Vārds...">
<br>
<input type="password" name="Password" placeholder="Parole...">
<br>
<input type="submit" value="Ienākt">
</form>
</div>
.log_inp input[type="username"] {
height: 28px;
width: 234px;
border: solid 1px #e4e4e4;
font-family: OpenSans-Italic;
color: #9a9a9a;
font-size: 13px;
padding-left:10px;
}
input {
padding: 0px;
}
<div class="log_inp">
<form action="#">
<input type="username" name="Username" placeholder="Vārds...">
<br>
<input type="password" name="Password" placeholder="Parole...">
<br>
<input type="submit" value="Ienākt">
</form>
</div>
With accepted answer cursor position of input is not modified.
You can move placeholder text of your input along with its cursor position via
input {
text-indent: 10px;
}
https://www.w3schools.com/csSref/pr_text_text-indent.asp
Check it out it might be helps u
input{
text-align:center;
}

How to move form to center of page

I am creating a registration form and am wondering how can I move the whole form to the center of the page? right now its all on the left side of the container, I want it to look a bit something like this: https://id2.s.nfl.com/fans/register?returnTo=http%3A%2F%2Fweeklypickem.fantasy.nfl.com%2F
#Regcontainer {
width: 1200px;
margin: 70px auto;
border: 1px solid;
background-color: aliceblue;
top: 0;
}
.Regcontainer h1 {
font-size: 40px;
font-family: 'Helvetica Neue', sans-serif;
color: black;
line-height: 1;
padding-left: 35px;
padding-top: 35px;
color: black;
}
input {
display: inline-block;
margin: 10px;
}
input[type=text] {
padding: 10px;
border: 2px solid #212;
border-radius: 2px;
box-shadow: #212121;
}
input[type=password] {
padding: 10px;
border: 2px solid #212;
border-radius: 2px;
padding: 5px 10px 5px 10px;
}
input[type=submit] {
background-color: #ff0000;
border: 1px solid #212121;
border-radius: 5px;
color: aliceblue;
font-weight: bold;
}
#back_form {
justify-content: center;
}
<div id="Registercontainer">
<div class="RegForm">
<h1> </h1>
<div id="back_glob">
<div id="back_form">
<form method="POST">
<label>FIRST NAME</label>
<input type="text" name="FName" />
<label>LAST NAME</label>
<input type="text" name="SNAME" />
<br/>
<label>EMAIL ADDRESS</label> <input id="email" name="email" type="text" />
<BR/>
<label>CREATE YOUR USERNAME</label> <input name="uname" type="text" /> <br/>
<label>CREATE PASSWORD</label> <input name="pass" type="password" />
<br/>
<input type="submit" name="valid" value="REGISTER" />
</form>
</div>
</div>
</div>
Here is the solution I came up with... but what does it do?
#Registercontainer needs to be on the center of the page. Meaning, your fixed with of 1200px is not going to work too well. I took the approach of reducing the size of your from container to give a better look and feel like this:
#Registercontainer {
max-width: 600px;
min-width: 320px;
width: 100%;
/* ... your other properties here ... */
}
Another note, your <label> needs the for attribute as specified in this article.
Let me know if you have any questions, FYI there are many ways to make this work for you.
#Registercontainer {
max-width: 600px;
min-width: 320px;
width: 100%;
margin: 70px auto;
border: 1px solid;
background-color: aliceblue;
top: 0;
padding: 15px;
}
.Regcontainer h1 {
font-size: 40px;
font-family: 'Helvetica Neue', sans-serif;
color: black;
line-height: 1;
padding-left: 35px;
padding-top: 35px;
color: black;
}
input {
display: inline-block;
margin: 10px;
}
input[type=text] {
padding: 10px;
border: 2px solid #212;
border-radius: 2px;
box-shadow: #212121;
}
input[type=password] {
padding: 10px;
border: 2px solid #212;
border-radius: 2px;
padding: 5px 10px 5px 10px;
}
input[type=submit] {
background-color: #ff0000;
border: 1px solid #212121;
border-radius: 5px;
color: aliceblue;
font-weight: bold;
}
#back_form {
justify-content: center;
}
<div id="Registercontainer">
<div class="RegForm">
<h1> Register With NackStack</h1>
<div id="back_glob">
<div id="back_form">
<form method="POST">
<label for="fname">FIRST NAME</label>
<input type="text" name="FName" id="fname" />
<br/>
<label for="sname">LAST NAME</label>
<input type="text" name="SNAME" id="sname" />
<br/>
<label for="email">EMAIL ADDRESS</label>
<input id="email" name="email" type="text" />
<br/>
<label for="uname">CREATE YOUR USERNAME</label>
<input name="uname" type="text" id="uname" />
<br/>
<label for="password">CREATE PASSWORD</label>
<input name="pass" type="password" id="password"/>
<br/>
<input type="submit" name="valid" value="REGISTER" />
</form>
</div>
</div>
</div>
Add margin:auto and a fixed width to the parent <div>. Example:
<div id="Registercontainer" style="margin-left:auto;margin-right:auto;width:250px">
Fiddle:
https://jsfiddle.net/mwatz122/g9ay26x3/
#Registercontainer {
text-align: center;
}
Please try this. It might help.
Put your form within a <div> like this:
<div align="center">
<!-- insert code here -->
</div>
Then in the CSS, add
form {
text-align: left;
}

CSS centered border

Hy everyone,
i want to have a border around a login form in html code, but with my current code, it isn't quite what i want. I want the border to really encapsulate the centered elements. any idea how to do that?
The result looks like this:
My code:
index.php:
<?php include "base.php"; ?>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<!DOCTYPE>
<html>
<title>Shopping List</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</html>
<head>
</head>
<body bgcolor=#878787>
<div class="form">
<center><h1>Please enter your login details</h1></center>
<form>
<label for="username">Username:</label><input type="text" name="username" id="username" > </br>
<label for="password">Password:</label><input type="text" name="password" id="password" > </br>
<input type="submit" name="login" id="login" value="Login">
</form>
</div>
</body>
style.css:
div.form{
text-align: center;
border: 5px solid;
border-radius: 25px;
box-shadow: 5px 5px 5px #888888;
}
.form label, .form input{
display: inline-block;
}
.form input {
width: 150px;
}
.form label {
width: 100px;
}
input {
border: 5px solid;
border-radius: 25px;
box-shadow: 5px 5px 5px #888888;
font-family: Trebuchet MS;
border: 1px solid #CCC;
margin-bottom: 5px;
background-color: #FFF;
padding: 2px;
}
input[type="submit"] {
display: inline-block;
position: relative;
margin-top: 5px;
width: 150px;
height: 30px;
left: 50px;
}
input:hover {
border: 1px solid #222;
background-color: #EEE;
}
try to add
.form{
max-width:320px;
margin:0 auto;
}
You could do that by reducing the width and centering your container ( div.form )
Something like
display:inline-block;
margin: 0 auto;
you can use CSS to put a border round whatever you want. for my example i will just surround the username and password fields with a solid black border:
HTML:
<div class="form">
<center><h1>Please enter your login details</h1></center>
<form>
<div class="border">
<label for="username">Username:</label><input type="text" name="username" id="username" > </br>
<label for="password">Password:</label><input type="text" name="password" id="password" > </br>
</div>
<input type="submit" name="login" id="login" value="Login">
</form>
</div>
The only change in the above HTML is i have put div's around the username and password section so the css knows which html to border around.
i then write this simple css:
.border {1px solid black;}
here a website with will show you what border styles there is out their.
http://www.w3schools.com/css/css_border.asp
You can resolve your issue by updating your CSS a little. Change these rules to the below CSS rules:
div.form {
text-align: center;
}
form {
padding: 20px;
display: inline-block;
border: 5px solid;
border-radius: 25px;
box-shadow: 5px 5px 5px #888888;
}
And then updated your HTML to the below HTML:
<div class="form">
<form>
<center><h1>Please enter your login details</h1></center>
<label for="username">Username:</label>
<input type="text" name="username" id="username" />
<br />
<label for="password">Password:</label>
<input type="text" name="password" id="password" />
<br />
<input type="submit" name="login" id="login" value="Login">
</form>
</div>
You would then have the following result:
I hope that helps you out.

Space between fieldsets how to remove it

I have created a simple login form. Here is a screenshot of the login form.
Here is the HTML code. I have used the 960 framework.
<article class="container_12">
<section id="login" class="grid_3">
<form action="POST">
<div id="loginheader"></div>
<fieldset class="logininputfields">
<input type="text" name="username" placeholder="Username" autofocus>
<input type="password" name="password" placeholder="Password">
</fieldset>
<fieldset class="submitfield">
<input type="submit" value="Log In">
</fieldset>
</form>
</section>
</article>
and here is the CSS
#login
{
height: 330px;
}
#loginheader
{
background: black;
height: 32px;
}
.logininputfields
{
background-color: #e5e5e5;
padding-left: 24px;
padding-bottom: 40px;
height: 160px;
}
.logininputfields input[type="text"],input[type="password"]
{
background: #c8cbcc;
margin-top: 30px;
border:1px solid #ccc;
color: #ededed;
font-weight: 600;
height: 30px;
width: 170px;
}
.submitfield input[type="submit"]
{
background: #0099ff;
border: 1px solid #ccc;
height: 42px;
width: 220px;
font-weight: 600;
font-size: large;
color: white;
}
.submitfield input[type="submit"]:hover
{
background: rgba(0,154,255,0.60);
}
I don't understand why there is a space between the submit button and the gray area. How can avoid it?
The browser you're viewing this in likely has default margins on all fieldsets. Try removing those margins page wide with something like this:
fieldset {
margin:0px;
padding:0px;
}
In my case, the above solution din't work. I have added a blank <Col></Col> in order to get space between the fieldsets.