Style input element to fill remaining width of its container
来源:互联网 发布:彩八仙时时彩软件 编辑:程序博客网 时间:2024/05/16 04:52
div总长一定,button长度会变化,需要input填满剩下的长度。
http://stackoverflow.com/a/11815907/2177408Here is a simple and clean solution without using JavaScript or table layout hacks. It is similar to this answer: Input text auto width filling 100% with other elements floating
It is important to wrap the input field with a span which is display:block
. Next thing is that the button has to come first and the the input field second.
Then you can float the button to the right and the input field fills the remaining space.
HTML
<form method="post"> <button>Search</button> <span><input type="text" title="Search" /></span></form>
CSS
form { width: 500px; overflow: hidden; background-color: yellow;}input { width: 100%;}span { display: block; overflow: hidden; padding-right:10px;}button { float: right;}
A simple fiddle: http://jsfiddle.net/v7YTT/90/
0 0
- Style input element to fill remaining width of its container
- element.offsetWidth 与 element.style.width的区别
- The Element Style of C++
- 格式化输出width,fill
- The Element of Style(一)
- How to upgrade docker container after its image changed
- The element style--Rule 1 to 5
- Total width of element (including padding and border) in jQuery
- Get pixel width of d3.js SVG element created with width as percentage
- Autocompletetextview width fill parent问题
- solution Of Pat 1033. To Fill or Not to Fill (25)
- obj.style.width
- JS 中的 style.width
- obj.style.width问题
- #431 – 绑定控件的宽度到高度(Binding a Control’s Width to Its Height)
- javascript错误解决:Unable to modify the parent container element before the child element is closed
- HTML Parsing Error: Unable to modify the parent container element before the child element is closed
- IE8报错:Unable to modify the parent container element before the child element is closed
- Android开发本地及网络Mp3音乐播放器(九)音乐收藏与列表切换
- 为什么要设置java环境变量
- 从头认识多线程-2.6 当异常出现时,线程自动释放锁
- <读书笔记>软件调试之道 :问题的核心-重现问题
- 诊断Java代码中常见的数据库性能热点问题应该这么做!
- Style input element to fill remaining width of its container
- Android杂记(3)FileUtils工具类梳理
- 欢迎使用CSDN-markdown编辑器
- php之自定义session存储机制【3】
- Keeloq解码软件实现
- typedefine 语法
- LeetCode 331. Verify Preorder Serialization of a Binary Tree(校验二叉树的前序遍历序列化)
- 使用Git上传本地代码到http://git.oschina.net/(SSH方式)
- Const