包装2块并在1行上显示

时间:2019-01-27 11:47:56

标签: php html html5 wrapper

我有2个街区,一个又一个。我想并排展示它们,但我的知识很薄弱。

{block name='product_flags_under'}
            {foreach $product.extraContent as $extra}
            {if $extra.moduleName=='ststickers'}
                {include file='catalog/_partials/miniatures/sticker.tpl' stickers=$extra.content sticker_position=array(10,11,13) is_from_product_page=1}
            {/if}
            {/foreach}
            {hook h='displayUnderProductName'}            
          {/block}

{block name='product_reference'}
            {if $sttheme.display_pro_reference && isset($product.reference_to_display)}
              <div class="product-reference pro_extra_info flex_container">
                <span class="pro_extra_info_label">{l s='Reference' d='Shop.Theme.Panda'}: </span>
                <div class="pro_extra_info_content flex_child" {if $sttheme.google_rich_snippets} itemprop="sku" {/if}>{$product.reference_to_display}</div>
              </div>
            {/if}

3 个答案:

答案 0 :(得分:0)

有很多方法可以执行这样的操作。我给你看了一个例子。您可以根据需要更改宽度百分比或将其删除。

.parent{
  display: flex
}
.left{
  width: 60%
}
.right{
  width: 40%
}
<div class="parent">    
 <div class="left">
   <p>t is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</p>
  </div>
 <div class="right">
      <p>t is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. </p>
  </div>
</div>

您可以在左侧和右侧块中包含其他元素

答案 1 :(得分:0)

您需要将两个块包装到另一个块中,以将块包装在div中。然后,您可以使用floatdisplay: flex并排显示两个div。

因为似乎您无法添加新块,所以您必须扩展一个块并删除另一个块。这是一个示例:

CSS

.product-wrapper {
   display: flex;
}

HTML

{block name='product_flags_under'}
<div class="product-wrapper">
    {$smarty.block.parent}    
    {if $sttheme.display_pro_reference && isset($product.reference_to_display)}
        <div class="product-reference pro_extra_info flex_container">
            <span class="pro_extra_info_label">{l s='Reference' d='Shop.Theme.Panda'}: </span>
            <div class="pro_extra_info_content flex_child" {if $sttheme.google_rich_snippets} itemprop="sku" {/if}>{$product.reference_to_display}</div>
        </div>
    {/if}   
</div>
{/block}

{block name='product_reference'}{/block}

答案 2 :(得分:0)

将两个DIV都包裹在父div中,然后使用flex创建2列布局

.parent {
    display: flex;
    flex-flow:row wrap;
    width: 100%;
}
.col {
  width: 45%;
  padding: 0 2%;
}

.col > div {border: 1px solid #000;}
<div class="parent">    
    <div class="col"><div>1</div></div>
    <div class="col"><div>2</div></div>
</div>