简体   繁体   English

通过浮动向右对齐Divs

[英]Aligning Divs By Floating Right

Im having trouble getting some divs to float and align properly. 我在让某些div浮动并正确对齐方面遇到麻烦。

I have two divs that contain images that are working properly, and I need to add two more, with images that behave the in the same manner. 我有两个div,其中包含工作正常的图像,我需要再添加两个,并且图像的行为方式相同。

I tried to use the same code to make the current divs work properly, but they automatically seem to remain allocate themselves within the same div as the other images that I'm trying to use. 我尝试使用相同的代码使当前的div正常工作,但是它们似乎自动将自己分配给与我要使用的其他图像相同的div。

//Here is the Code. //这里是代码。

<div id="products">
        <img src="cbdog.jpg" style="float: left; padding-bottom: 25px;">
        <br>
        <br>
    </div>
    <div id="otherProducts">
        <br>
        <br>
    <img src="gelog.jpg" style="float: left;">
    </div>

Im trying to this is inline obvisouly. 我试图这样做是内联的。

So I tried to do. 所以我尝试去做。

<div id="products">
        <img src="cbdog.jpg" style="float: left; padding-bottom: 25px;">
        <br>
        <br>
    </div>
    <div id="otherProducts">
        <br>
        <br>
    <img src="gelog.jpg" style="float: left;">
    </div>
<div id="cbdGel">
        <br>
        <br>
    <img src="gelog.jpg" style="float: left;">
    </div>

And Basically replicate the previous formatting to get the same result, but the resulting image just places itself with the same div as the top image. 并且基本上复制以前的格式以获得相同的结果,但是所得的图像只是将自身放置在与顶部图像相同的div上。

Any help would be greatly appreciated. 任何帮助将不胜感激。 Thanks in advance. 提前致谢。

~zaklikescode 〜zaklikescode

If i understand correctly, you want two divs side by side? 如果我理解正确,您是否希望两个div并排? if so. 如果是这样的话。 You'll need to assign a width and position either inline using the style="" attribute or in css 您需要使用style=""属性或在CSS中内联分配宽度和位置

#products, #otherproducts { float:left; width:48%; position:absolute; }

if not, let me know. 如果没有,请告诉我。 I'll see what i can do. 我会看看我能做什么。

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

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