jsf创建浮动式标签

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html">
    <h:head>
        <title>Facelet Title</title>
<style type="text/css">
                form{  
                    /*margin: 5em;*/  
                    backface-visibility: hidden;  
                } 
                .input{  
                    position: relative;  
                    float: left;  
                    margin: 10px;  
                }  
                input{  
                    border: 1px solid #eee;  
                    padding: 1.5em 0.5em 0.5em 0.5em;  
                    outline: none;  
                } 
                input + label {   
                    position:absolute;  
                    left:10px;  
                    top:5%;  
                    /*transform:translateY(-50%);*/  
                    color:#aaa;  
                    /*transition:all .2s ease;*/  
                }
                input:focus + label{  
                    color: #52A5FB;  
                    /*                    font-size: .65em;  */
                    top: 5%;  
                    /*transform: none;*/
                }
                .not-empty + label {  
                    color:#aaa;  
                } 
            </style> 
    </h:head>
    <h:body>
       <h:form>
                <div class="input">
                    <input type="text" id="name"/>
                    <label for="name">YourName</label>
                </div>
                <div class="input">
                    <input type="text" id="address"/>
                    <label for="address">Your address</label>
                </div>
                <div class="input">
                    <h:inputText id="tel"/>
                    <h:outputLabel for="tel" value="电话"/>
                </div>
                <h:panelGroup class="input">
                    <h:inputText id="email"/>
                    <h:outputLabel for="email" value="邮箱"/>
                </h:panelGroup>
                <script>
                    var inputs = document.getElementsByTagName('input');
                    for (i = 0; !(i >= inputs.length); i++) {
                        var input = inputs[i];
                        input.addEventListener('keyup', bindUI, false);
                    }
                    function bindUI() {
                        if (this.value) {
                            this.classList.add('not-empty');
                        } else {
                            this.classList.remove('not-empty');
                        }
                    }
                </script>

            </h:form>
    </h:body>
</html>


效果如下:


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值