开发者

css alignment with previous sibling

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜