开发者

css alignment with previous sibling

开发者 https://www.devze.com 2023-03-24 18:47 出处:网络
Considering the following : http://jsfiddle.net/Johnny5/EC8kK/ I would like the input button to align right with the inner div, without wrapping with another element. Example :

Considering the following : http://jsfiddle.net/Johnny5/EC8kK/

I would like the input button to align right with the inner div, without wrapping with another element. Example :

|---div.container-------------------|
|                                   |
| |--div.box---------------|        |
| |                        |        |
| |------------------------|        |
|                               开发者_如何转开发    |
|                |--input--|        |
|                |---------|        |
|                                   |
|-----------------------------------|

The width of .box is known, but not the width of the input. So I can't calculate exactly the margin-left for that input. I don't want to add a container <div> around .box and input. Don't really care for IE <= 7.

The ideal solution will modify only the css, without adding html markups.

Any suggestions?


Here is the fiddle

http://jsfiddle.net/RcNSN/

And here is a code without modifying HTML. adjust the right margin, once you remove the borders.

http://jsfiddle.net/RcNSN/2/


What about something like this: http://jsfiddle.net/bGE2J/? It should work as long as your container isn't fluid.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号