简体   繁体   English

并排显示div

[英]displaying div side by side

I am having some issues trying to display my <div checkoutoptions to the right and my <div productdetails to the left of checkoutoptions 我在尝试在我的<div checkoutoptions右边显示我的<div productdetails在左边的checkoutoptions <div productdetails上遇到一些问题

Here is how it is displaying now 现在是这样显示的 正在显示 :

Here is how I would like it to display 这是我想要的显示方式 面板名为

It looks like there is some kind of wrapping around the div checkoutoptions that won't let me move the div productdetails up but I have not idea how to correct the issue. 似乎在div checkoutoptions周围有某种包装,它不允许我将div productdetails up移动div productdetails up但我不知道如何解决此问题。

Here is a link to my website as an example if you would like to see it first hand. 如果您想直接看一下,这里是我网站的链接。

Here is my HTML: 这是我的HTML:

    <!-- Share and title/show this panel on top -->


        <div class="ProductMain" style= "float: left; "> 
            <h1 itemprop="name">%%GLOBAL_ProductName%%</h1>

            %%GLOBAL_FacebookLikeButtonAbove%%
            %%GLOBAL_FacebookLikeButtonBelow%%
            %%GLOBAL_PinterestButton%%


            <!--side panel with add to cart show this panel to the right-->

            <div id="checkoutoptions">

               %%SNIPPET_ProductAddToCartRight%%
               <div><input id="ShopButton" style="display: none";></div>


               %%SNIPPET_ProductAddToCartBelow%%
               %%Panel.SideProductAddToWishList%%


                          <div class="WishlistRow DetailRow" style="display:%%GLOBAL_HideWishlist%%">
                              <a class="WishListButton" href="javascript: void(0)">ADD TO WISHLIST</a>

                </div>

                              %%GLOBAL_AddThisLink%%

            </div>


            <!--Yotpo Reviews/ display this panel next to checkoutoptions to the left and right under ProductMain-->

            <div id="productdetails">

<div style="padding: 0px 0px 0px; width: 200px; margin: auto; height: 00px"> </div><!--yotpo product rating-->

 <div class="yotpo bottomLine"
 data-product-id="%%GLOBAL_ProductId%%"
 data-url="%%GLOBAL_ProductLink%%">
    </div> 


            <div class="ProductDetailsGrid">
                <div class="DetailRow RetailPrice" style="display: %%GLOBAL_HideRRP%%">
                    <span class="Label">%%LNG_RRP%%:</span>
                    %%GLOBAL_RetailPrice%%
                    %%GLOBAL_YouSave%%
                </div>
</div>

Here is my CSS so far: 到目前为止,这是我的CSS:

#checkoutoptions{
    margin:auto;
    padding: 10px;
    border-radius: 5px;
    width: 310px;
    border: 1px solid gray;
}

Switch place on the div with review and the div with product info. 在带有评论的div和在带产品信息的div上切换位置。 Result will be like 结果会像

结果

<div class="yotpo bottomLine yotpo-medium" data-product-id="705" data-url="" data-yotpo-element-id="2">
..... content
</div>
<div class="ProductDetailsGrid">
....content
</div>

should instead be rearranged to 而是应该重新安排为

<div class="ProductDetailsGrid">
....content
</div>
<div class="yotpo bottomLine yotpo-medium" data-product-id="705" data-url="" data-yotpo-element-id="2">
..... content
</div>

Doesn't look exactly like you wished for, but I believe it's quite good. 看起来并不完全符合您的要求,但我相信它非常好。

Actually the order/structure of elements is not good. 实际上,元素的顺序/结构不好。 You should restructure your html and create small containers for each section. 您应该重组HTML并为每个部分创建一个小的容器。

For example. 例如。

<div class="post-meta">
   <div class="share-box">
      <div class="share-buttons"><!-- fb and pinterest buttons --></div>
      <div class="product-price-rating"><!-- item price, rating etc --></div>
   </div>
   <div class="cart-box">
       <!-- cart and other code -->
   </div>
   <div class="clearfix"></div>
</div>

Now you can easily achieve the layout you want by floating each box and clearing float before closing parent. 现在,您可以通过floating每个框并在关闭父级之前清除float来轻松实现所需的布局。

.share-box{
  float: left;
}

.cart-box{
  float: right;
}
.clearfix{
  clear: both;
}

添加到您的CSS类:

display: inline-block;

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

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