HTML   发布时间:2022-04-14  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了html – 在焦点上展开输入字段大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我想在焦点上向左侧展开一个搜索框.以下代码将扩展,但它将向右扩展.无论如何将它扩展到左边?

HTML

<input type="text" placeholder="search">

CSS:

input[type="text"] {
    BACkground: #444;
    border: 0 none;
    color: #d7d7d7;
    width:50px;
    padding: 6px 15px 6px 35px;
    -webkit-border-radius: 20px;
    -moz-border-radius: 20px;
    border-radius: 20px;
     margin:3px 12px;
}

input[type="text"]:focus {
    BACkground:#ccc;
    color: #6a6f75;
    width: 120px;    
    margin:3px 12px;
    outline: none;
}

input[type="text"] {
    -webkit-transition: all 0.7s ease 0s;
    -moz-transition: all 0.7s ease 0s;
    -o-transition: all 0.7s ease 0s;
    transition: all 0.7s ease 0s;
}

演示:
http://jsfiddle.net/7ppaS/

解决方法

如何使用padding-left使其向左扩展,同时更改margin-left以使输入框保持在同一位置:
input[type="text"] {
    BACkground: #444;
    border: 0 none;
    color: #d7d7d7;
    width:50px;
    padding: 6px 15px 6px 35px;
    -webkit-border-radius: 20px;
    -moz-border-radius: 20px;
    border-radius: 20px;
     margin:3px 80px;
}

input[type="text"]:focus {
    BACkground:#ccc;
    color: #6a6f75;
    padding-left:80px;  
    margin-left:35px;
    outline: none;
}

演示:http://jsfiddle.net/7ppaS/4/

大佬总结

以上是大佬教程为你收集整理的html – 在焦点上展开输入字段全部内容,希望文章能够帮你解决html – 在焦点上展开输入字段所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。