包裹2个块并在1行显示它们

问题描述 投票:0回答:3

我有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}
php html html5 wrapper
3个回答
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>

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


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>

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}
© www.soinside.com 2019 - 2024. All rights reserved.