簡體   English   中英

如何更改CSS3搜索框的展開方向

[英]How to change expanding direction of css3 search box

我正在使用下面的css3搜索框代碼,我想知道如何從左到右更改搜索框的擴展方向

 @import url(http://fonts.googleapis.com/css?family=Lato:100,300,400,700); @import url(https://raw.github.com/FortAwesome/Font-Awesome/master/docs/assets/css/font-awesome.min.css); body { background: #DDD; font-size: 15px; } #wrap { margin: 50px 100px; display: inline-block; position: relative; height: 60px; float: right; padding: 0; position: relative; } input[type="text"] { height: 60px; font-size: 55px; display: inline-block; font-family: "Lato"; font-weight: 100; border: none; outline: none; color: #555; padding: 3px; padding-right: 60px; width: 0px; position: absolute; top: 0; right: 0; background: none; z-index: 3; transition: width .4s cubic-bezier(0.000, 0.795, 0.000, 1.000); cursor: pointer; } input[type="text"]:focus:hover { border-bottom: 1px solid #BBB; } input[type="text"]:focus { width: 700px; z-index: 1; border-bottom: 1px solid #BBB; cursor: text; } input[type="submit"] { height: 67px; width: 63px; display: inline-block; color:red; float: right; background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADNQTFRFU1NT9fX1lJSUXl5e1dXVfn5+c3Nz6urqv7+/tLS0iYmJqampn5+fysrK39/faWlp////Vi4ZywAAABF0Uk5T/////////////////////wAlrZliAAABLklEQVR42rSWWRbDIAhFHeOUtN3/ags1zaA4cHrKZ8JFRHwoXkwTvwGP1Qo0bYObAPwiLmbNAHBWFBZlD9j0JxflDViIObNHG/Do8PRHTJk0TezAhv7qloK0JJEBh+F8+U/hopIELOWfiZUCDOZD1RADOQKA75oq4cvVkcT+OdHnqqpQCITWAjnWVgGQUWz12lJuGwGoaWgBKzRVBcCypgUkOAoWgBX/L0CmxN40u6xwcIJ1cOzWYDffp3axsQOyvdkXiH9FKRFwPRHYZUaXMgPLeiW7QhbDRciyLXJaKheCuLbiVoqx1DVRyH26yb0hsuoOFEPsoz+BVE0MRlZNjGZcRQyHYkmMp2hBTIzdkzCTc/pLqOnBrk7/yZdAOq/q5NPBH1f7x7fGP4C3AAMAQrhzX9zhcGsAAAAASUVORK5CYII=) center center no-repeat; text-indent: -10000px; border: none; position: absolute; top: 0; right: 0; z-index: 2; cursor: pointer; opacity: 0.4; cursor: pointer; transition: opacity .4s ease; } input[type="submit"]:hover { opacity: 0.8; } 
 <div id="wrap"> <form action="" autocomplete="on"> <input id="search" name="search" type="text" placeholder="What're we looking for ?"><input id="search_submit" value="Rechercher" type="submit"> </form> </div> 

一切似乎都正常,只是我需要將其滑向正確的方向

 body { background: #DDD; font-size: 15px; } #wrap { margin: 50px 100px; display: inline-block; position: relative; height: 60px; float: left; padding: 0; position: relative; } input[type="text"] { height: 60px; font-size: 55px; display: inline-block; font-family: "Lato"; font-weight: 100; border: none; outline: none; color: #555; padding: 3px; padding-left: 60px; width: 0px; position: absolute; top: 0; left: 0; background: none; z-index: 3; transition: width .4s cubic-bezier(0.000, 0.795, 0.000, 1.000); cursor: pointer; } input[type="text"]:focus:hover { border-bottom: 1px solid #BBB; } input[type="text"]:focus { width: 700px; z-index: 1; border-bottom: 1px solid #BBB; cursor: text; } input[type="submit"] { height: 67px; width: 63px; display: inline-block; color:red; float: left; background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADNQTFRFU1NT9fX1lJSUXl5e1dXVfn5+c3Nz6urqv7+/tLS0iYmJqampn5+fysrK39/faWlp////Vi4ZywAAABF0Uk5T/////////////////////wAlrZliAAABLklEQVR42rSWWRbDIAhFHeOUtN3/ags1zaA4cHrKZ8JFRHwoXkwTvwGP1Qo0bYObAPwiLmbNAHBWFBZlD9j0JxflDViIObNHG/Do8PRHTJk0TezAhv7qloK0JJEBh+F8+U/hopIELOWfiZUCDOZD1RADOQKA75oq4cvVkcT+OdHnqqpQCITWAjnWVgGQUWz12lJuGwGoaWgBKzRVBcCypgUkOAoWgBX/L0CmxN40u6xwcIJ1cOzWYDffp3axsQOyvdkXiH9FKRFwPRHYZUaXMgPLeiW7QhbDRciyLXJaKheCuLbiVoqx1DVRyH26yb0hsuoOFEPsoz+BVE0MRlZNjGZcRQyHYkmMp2hBTIzdkzCTc/pLqOnBrk7/yZdAOq/q5NPBH1f7x7fGP4C3AAMAQrhzX9zhcGsAAAAASUVORK5CYII=) center center no-repeat; text-indent: -10000px; border: none; position: absolute; top: 0; left: 0; z-index: 2; cursor: pointer; opacity: 0.4; cursor: pointer; transition: opacity .4s ease; } input[type="submit"]:hover { opacity: 0.8; } 
 <div id="wrap"> <form action="" autocomplete="on"> <input id="search" name="search" type="text" placeholder="What're we looking for ?"><input id="search_submit" value="Rechercher" type="submit"> </form> </div> 

像這樣

 body { background: #DDD; font-size: 15px; } #wrap { margin: 50px 100px; display: inline-block; position: relative; height: 60px; float: right; padding: 0; position: relative; } input[type="text"] { height: 60px; font-size: 30px; display: block; font-family: "Lato"; font-weight: 200; outline: none; border:none; color: black; padding-right: 400px; width: 100%; position: absolute; float: left; top: 0; right: 0; background: none; z-index: 3; transition: all .4s ; cursor: pointer; opacity:0; } input[type="text"]:focus:hover { border-bottom: 1px solid #BBB; } input[type="text"]:focus { padding-right: 0px; opacity:1; border:normal; z-index: 1; border-bottom: 1px solid #BBB; cursor: text; } input[type="submit"] { height: 67px; width: 63px; display: inline-block; color:red; float: right; background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADNQTFRFU1NT9fX1lJSUXl5e1dXVfn5+c3Nz6urqv7+/tLS0iYmJqampn5+fysrK39/faWlp////Vi4ZywAAABF0Uk5T/////////////////////wAlrZliAAABLklEQVR42rSWWRbDIAhFHeOUtN3/ags1zaA4cHrKZ8JFRHwoXkwTvwGP1Qo0bYObAPwiLmbNAHBWFBZlD9j0JxflDViIObNHG/Do8PRHTJk0TezAhv7qloK0JJEBh+F8+U/hopIELOWfiZUCDOZD1RADOQKA75oq4cvVkcT+OdHnqqpQCITWAjnWVgGQUWz12lJuGwGoaWgBKzRVBcCypgUkOAoWgBX/L0CmxN40u6xwcIJ1cOzWYDffp3axsQOyvdkXiH9FKRFwPRHYZUaXMgPLeiW7QhbDRciyLXJaKheCuLbiVoqx1DVRyH26yb0hsuoOFEPsoz+BVE0MRlZNjGZcRQyHYkmMp2hBTIzdkzCTc/pLqOnBrk7/yZdAOq/q5NPBH1f7x7fGP4C3AAMAQrhzX9zhcGsAAAAASUVORK5CYII=) center center no-repeat; text-indent: -10000px; border: none; position: absolute; top: 0; right: 0; z-index: 2; cursor: pointer; opacity: 0.4; cursor: pointer; transition: opacity .4s ease; } input[type="submit"]:hover { opacity: 0.8; } form { width: 460px; overflow:hidden; } 
 <div id="wrap"> <form action="" autocomplete="on" onclick='return false'> <input id="search" name="search" type="text" placeholder="What're we looking for ?" ><input id="search_submit" value="Rechercher" type="submit"> </form> </div> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM