How to stretch the width of an element, so that it's 100% - widths of its siblings?

前端 未结 11 2303
悲&欢浪女
悲&欢浪女 2020-12-12 18:41

Say, I have the following unordered list. The button has width: auto. How do I style the elements, so #textField would stretch as much as possible,

11条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-12 19:05

    Tables and positioning are not required at all. The answer is to float one element left, and the other right.

    http://jsfiddle.net/johnallan/HeUSN/

    HTML:

    • b blah blah blah blah blah blah blah blah blahblah blah blahblah blah blah blah blah blahblah blah blahblah blah blahblah blah blah blah blah blahlah blah blah

    CSS:

    .media{ border:1px solid black }
    .media, .copy{overflow:hidden; _overflow:visible; zoom:1;}
    .media .button{float:left; margin-right: 10px;}
    

提交回复
热议问题