Last active
September 22, 2019 16:21
-
-
Save Fujihai/f70d642c8a6e33b511a3436514a67da1 to your computer and use it in GitHub Desktop.
Material Design input text demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="v-input__slot"> | |
<fieldset aria-hidden="true"> | |
<!-- <legend style="width: 56px;"><span></span></legend> --> | |
</fieldset> | |
<div class="v-text-field__slot"> | |
<input id="input-1894" type="text"/> | |
<label for="input-1894" class="v-label theme--light" style="left: 0px; right: auto; position: absolute;">Outlined</label> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.querySelector("#input-1894").onclick = function() { | |
removeAllChildren('fieldset'); | |
appendLegendNode('fieldset'); | |
}; | |
document.querySelector("#input-1894").onblur = function() { | |
removeAllChildren('fieldset'); | |
}; | |
document.querySelector("#input-1894").addEventListener("mouseenter", function(event) { | |
document.querySelector("fieldset").style.border = "1px solid #000000"; | |
}, false); | |
function removeAllChildren(domSelector) { | |
var p = document.querySelector(domSelector); | |
var childs = p.childNodes; | |
for(var i = 0; i < childs.length; i++) { | |
p.removeChild(childs[i]); | |
} | |
} | |
function appendLegendNode(domSelector) { | |
var p = document.createElement('legend'); | |
p.style.width = "56px"; | |
document.querySelector(domSelector).appendChild(p); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.v-input__slot { | |
position: relative; | |
} | |
.v-input__slot fieldset { | |
min-height: 50px; | |
border-radius: 10px; | |
border: 1px solid #C2C2C2; | |
} | |
.fieldset-hover-active { | |
border: 1px solid #000000; | |
} | |
.v-text-field__slot { | |
position: absolute; | |
min-height: 50px; | |
position: absolute; | |
left: 16px; | |
right: 0; | |
top: 15px; | |
bottom: 0; | |
} | |
.v-text-field__slot input { | |
border: none; | |
outline: none; | |
height: 50px; | |
line-height: 50px; | |
font-size: 1.3em; | |
} | |
.v-label { | |
position: absolute; | |
bottom: 17px; | |
font-size: 1.3em; | |
color: #ccc; | |
transition: all ease 0.3s; | |
pointer-events: none; | |
} | |
input:focus + label { | |
color: #f60; | |
font-size: 0.8em; | |
transform: translateY(-40px); | |
margin: 0 2px 0 2px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment