简体   繁体   English

我的两个div不会彼此堆叠

[英]My two div's won't stack next to each other

I have two divs, wrapped inside a bigger div. 我有两个div,包裹在一个较大的div中。 I need to stack them next to each other rather than have them display as blocks that they typically do. 我需要将它们彼此相邻堆叠,而不是像通常那样将它们显示为块。 I followed suggestions on similar stackoverflow questions and floated the first inner div to the left and floated the 2nd inner div to the right. 我遵循有关类似stackoverflow问题的建议,将第一个内部div浮动到左侧,将第二个内部div浮动到右侧。 No success. 没有成功

I floated both inner div's to left and set overflow:hidden to the wrapper div. 我将两个内部div都向左浮动,并将overflow:hidden隐藏到包装div中。 No success. 没有成功 I also, set both the inner div display's to an inline-block type. 我也将两个内部div显示器都设置为嵌入式块类型。 No success. 没有成功 They all stack over each other and this is not what I want. 它们都相互堆叠,这不是我想要的。

Here is the semantic markup along with the CSS: 这是语义标记以及CSS:

<div align="left" style="border:2px dotted #fff;margin-top:5px;">
           <!--  <span class="hyperlink_message">This is the message, redundant</span>      -->
                <div class="hyperlink preview" style=";padding-top:8px;border:1px solid #bbc5ee;">  
                    <div style="float:left;">
                        <a href="https://www.facebook.com/parijat" target="_blank">
                            <img src="https://sphotos-b.xx.fbcdn.net/hphotos-ash4/395790_10150612393596211_887151733_n.jpg" alt="image not found" style="width:100px;height:100px;border:solid 1px gray;margin-right:5px;" ></img>
                        </a>
                    </div>
                    <div style="float:left;">
                        <div style="font-size:12px;color:black;"><a href="{$hyperlinktext[i].url}"><b>My Facebook page</b></a></div>
                        <div style="font-size:10px;color:gray;">www.facebook.com</div>
                        <div style="padding-top:5px;font-size:10px;color:gray;">Facebook is a social utility that connects people with friends and others who work, study and live around them. People use Facebook to keep up with friends, upload an unlimited number of photos, post links and videos, and learn more about the people they meet.</div>
                    </div>
                    <div style="clear: both"></div> 
                </div>
</div>

(please excuse the CSS styles included along with the markup, dabbling with some terrible legacy code at the moment. (请原谅标记中包含的CSS样式,此刻正在尝试一些糟糕的旧代码。

And the corresponding JSFiddle. 和对应的JSFiddle。

http://jsfiddle.net/hpTym/ http://jsfiddle.net/hpTym/

What do you guys think is going wrong here? 你们觉得这里出了什么问题?

设置浮动div的宽度,还是需要它们浮动而没有特定的宽度?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM