Div stretch then wrap around other floated div

泪湿孤枕 提交于 2019-12-13 08:34:49

问题


I'm struggling trying to get the behavior that I want with CSS.

I created a JSFiddle here that shows my problem: http://jsfiddle.net/c2Snd/

I want my #left div's width to stretch, but only as far as the #right div.

Basically, I want my #left divs to wrap around my #right dive just like text would. So in my JSFiddle, the top 2 red boxes' width would be 50%, then the bottom red box's width would be 100%.


回答1:


Looks like you just about have it.. confused: http://jsfiddle.net/BCBd2/1/




回答2:


Well I do not know if there are any shortcuts to doing this, but try this re-Fiddle.. http://jsfiddle.net/c2Snd/1/ To make something like this you will need to use percentage in width and border-width, so they are proportional to eachother.




回答3:


Does it serves your purpose?

http://jsfiddle.net/c2Snd/2/



来源:https://stackoverflow.com/questions/10129818/div-stretch-then-wrap-around-other-floated-div

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!