Skip to content

Instantly share code, notes, and snippets.

@ben-z
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ben-z/02ac210d73b6e90ba6a1 to your computer and use it in GitHub Desktop.
Save ben-z/02ac210d73b6e90ba6a1 to your computer and use it in GitHub Desktop.
Simple Log In Form with css. Preview on Codepen: http://codepen.io/anon/pen/azrmoB
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="author" content="http://github.com/ben-z/">
<meta name="license" content="ISC">
<title>Log In</title>
<link rel="stylesheet" href="main.css">
</head>
<body>
<div id="content">
<form class="login">
<i class="user-icon"></i><input type="text" placeholder="Username" />
<br />
<i class="key-icon"></i><input type="password" placeholder="Password" />
</form>
</div>
</body>
</html>
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
// Mixins are like functions,
// they are used throughout the code
@mixin placeholder-color($color) {
&::-webkit-input-placeholder {
@include font-attr($color);
}
&:-moz-placeholder { /* Firefox 18- */
@include font-attr($color);
}
&::-moz-placeholder { /* Firefox 19+ */
@include font-attr($color);
}
&:-ms-input-placeholder {
@include font-attr($color);
}
}
@mixin font-attr($color){
color: $color;
font-family: HelveticaNeue;
font-size: 15px;
line-height: 34px;
vertical-align: bottom;
}
@mixin icon($url){
display: inline-block;
content: url($url);
height: 34px;
width: 34px;
vertical-align: text-top;
}
// -----------------------------
body {
background-color: black;
}
input{
letter-spacing: 1px;
}
#content{
text-align: center;
}
form.login {
// Optional: Just to make the form
// look nicer on the empty webpage
display: inline-block;
margin-top: 50px;
text-align: left;
border: 1px solid white;
padding: 5px 30px 30px 30px;
// -----------------------------
// Custom icons I traced
.user-icon {
@include icon('assets/user.svg');
}
.key-icon {
@include icon('assets/key.svg');
}
// -----------------------------
input{
display:inline-block;
background: none;
border: none;
border-bottom: 1px solid white;
margin: 25px 0 0 7px;
padding: 0 0 0 5px;
@include font-attr(white);
// here you can change the placeholder color
// try changing 'white' to 'darken(white, 20%)'
@include placeholder-color(white);
&:focus{
outline-width: 0;
}
}
}
Display the source blob
Display the rendered blob
Raw
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="34px" height="34px" viewBox="0 0 34 34" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
<!-- Generator: Sketch 3.1.1 (8761) - http://www.bohemiancoding.com/sketch -->
<title>user</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
<g id="Mobile-Portrait" sketch:type="MSArtboardGroup" transform="translate(-27.000000, -50.000000)">
<g id="user" sketch:type="MSLayerGroup" transform="translate(27.000000, 50.000000)">
<path d="M17.5,31 C24.9558441,31 31,24.9558441 31,17.5 C31,10.0441559 24.9558441,4 17.5,4 C10.0441559,4 4,10.0441559 4,17.5 C4,24.9558441 10.0441559,31 17.5,31 Z" id="Oval-1" stroke="#FEFEFE" stroke-width="2" sketch:type="MSShapeGroup"></path>
<circle id="Oval-2" stroke="#FEFEFE" fill="#FEFEFE" sketch:type="MSShapeGroup" cx="18" cy="12" r="4"></circle>
<path d="M16.4929889,17 C13.4592949,17 11,19.4686147 11,22.5 L11,28 L25,28 L25,22.5 C25,19.4624339 22.5293078,17 19.5070111,17 L16.4929889,17 Z" id="Rectangle-1" fill="#FEFEFE" sketch:type="MSShapeGroup"></path>
<rect id="Rectangle-3" stroke="transparent" sketch:type="MSShapeGroup" x="0" y="0" width="34" height="34"></rect>
</g>
</g>
</g>
</svg>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment