Floating labels with CSS only
How do I make an floating labels with css only?
Just an CSS-only experiment that I wanted to share. =) I'm still improving it.Tested on Google Chrome (mobile too), Firefox and Opera.. What is a floating labels with css only? How do you make a floating labels with css only? This script and codes were developed by Diéssica Gurskas on 10 January 2023, Tuesday.
Floating labels with CSS only - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Floating labels with CSS only</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel='stylesheet prefetch' href='https://fonts.googleapis.com/css?family=Open+Sans'> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ input, label { padding: 30px 30px 10px 30px;
}
input { /* visual */ width: 100%; height: 75px; opacity: 0.5; background: #2c3e50; box-shadow: 9.375px 9.375px 0 #1e2a36; border: 0; border-radius: 6.25px; transition: all 700ms ease-in;
}
input:focus { background: #4d346b; box-shadow: 9.375px 9.375px 0 #392750;
}
label { /* on */ display: inline-block; position: relative; top: -75px; left: 0; /* end state */ transition: all 300ms ease 9999999s; /* visual */ text-transform: uppercase;
}
input:focus + label { top: -88px; /* visual */ font-size: 12.5px; font-weight: bold; /* end state */ transition: all ease 300ms;
}
* { box-sizing: border-box;
}
body, input { color: #fff;
}
body { font-family: "Open Sans"; background: url(https://i.imgur.com/D3HiN8e.jpg); /* center vertically */ position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 600px; height: 450px; margin: auto;
}
h1, h2 { font-weight: normal; text-align: center;
}
h1 { font-weight: bold; text-transform: uppercase; margin-bottom: 60px;
}
input.center { text-align: center;
}
label.center { width: 600px; text-align: center;
}
h2 { opacity: 0.5; margin-top: -40px;
}
label { cursor: text;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body>
<h1>Floating labels with CSS only</h1>
<h2>~ default ~</h2>
<input id="email"/>
<label for="email">Your e-mail</label>
<h2>~ center ~</h2>
<input class="center" id="live"/>
<label class="center" for="live">Where do you live?</label> <script src="js/index.js"></script>
</body>
</html>
Floating labels with CSS only - Script Codes CSS Codes
input, label { padding: 30px 30px 10px 30px;
}
input { /* visual */ width: 100%; height: 75px; opacity: 0.5; background: #2c3e50; box-shadow: 9.375px 9.375px 0 #1e2a36; border: 0; border-radius: 6.25px; transition: all 700ms ease-in;
}
input:focus { background: #4d346b; box-shadow: 9.375px 9.375px 0 #392750;
}
label { /* on */ display: inline-block; position: relative; top: -75px; left: 0; /* end state */ transition: all 300ms ease 9999999s; /* visual */ text-transform: uppercase;
}
input:focus + label { top: -88px; /* visual */ font-size: 12.5px; font-weight: bold; /* end state */ transition: all ease 300ms;
}
* { box-sizing: border-box;
}
body, input { color: #fff;
}
body { font-family: "Open Sans"; background: url(https://i.imgur.com/D3HiN8e.jpg); /* center vertically */ position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 600px; height: 450px; margin: auto;
}
h1, h2 { font-weight: normal; text-align: center;
}
h1 { font-weight: bold; text-transform: uppercase; margin-bottom: 60px;
}
input.center { text-align: center;
}
label.center { width: 600px; text-align: center;
}
h2 { opacity: 0.5; margin-top: -40px;
}
label { cursor: text;
}
Floating labels with CSS only - Script Codes JS Codes
// I'm still improving it!
// Inspiration: http://dribbble.com/shots/1254439--GIF-Float-Label-Form-Interaction
![Floating labels with CSS only - Script Codes](http://shots.codepen.io/diessica/pen/tIBhj-512.jpg)
Developer | Diéssica Gurskas |
Username | diessica |
Uploaded | January 10, 2023 |
Rating | 4 |
Size | 3,966 Kb |
Views | 6,072 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
CSS Sine Waves | 4,102 Kb |
Equal Height Columns Sass mixin | 3,861 Kb |
Colunas de mesma altura | 2,479 Kb |
Hover to show the text | 3,395 Kb |
CSS Tube explodes | 5,035 Kb |
Tooltip with title attribute | 1,663 Kb |
CSS is AWESOME | 3,349 Kb |
Pure CSS Waves | 3,446 Kb |
A CSS curve | 3,007 Kb |
How checkbox hack works | 4,120 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Materializecss input form | Jasonchan | 1,443 Kb |
Dice | Fraina | 5,026 Kb |
3D-box | Parthviroja | 2,346 Kb |
Sticky div | Kaslab | 2,225 Kb |
Css3 loader | Clknap | 2,391 Kb |
Buttons for autumn | Nikazawila | 1,795 Kb |
Twitch | SarahDunlap | 2,937 Kb |
Nice textured background | Hans | 2,659 Kb |
Fellowship of the Ring | Aussieyang | 2,639 Kb |
After America | Jonathangarner | 2,686 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!