我如何在同一页面中拥有两种不同的样式



我在循环内部有两个div ,我需要将样式与另一个样式放在另一个div 。>

我不知道我是否可以使用PHP,JS或CSS进行操作。这是我的代码:

- 样式(此样式在同一页面中,因为我有一种一般风格( -

    <?php
    $style_1 = '<style>
        .content .postcontent-0 .layout-item-0 { margin-bottom: 7px;  }
        .content .postcontent-0 .layout-item-1 { border-spacing: 10px 0px; border-collapse: separate;  }
        .content .postcontent-0 .layout-item-2 { border-top-style:solid; background: #ffffff;  }
    </style>';
    $style_2 = '<style>
        .content .postcontent-0 .layout-item-0 { color: #083752; background: ;  border-collapse: separate;  }
        .content .postcontent-0 .layout-item-1 { color: #083752;  }
        .content .postcontent-0 .layout-item-2 { border-style:Double; border-radius: 15px;  }
        .content .postcontent-0 .layout-item-3 { padding-right: 10px;padding-left: 10px;  }
          </style>';
    ?>

- 视图

<?php for ($i = 0; $i < $contador; $i++) { ?>
<!--Here begin the STYLE_1-->
    <div class="content-layout-wrapper layout-item-0">
       <div class="content-layout layout-item-1">
         <div class="content-layout-row">
           <div class="layout-cell layout-item-2">
             <p> Text #1 </p>
           </div>
         </div>
        </div>
     </div>
    <!--Here END the STYLE_1-->
    <!--Here begin the STYLE_2-->
     <div class="postcontent postcontent-0 clearfix">
        <div class="content-layout-wrapper layout-item-0">
            <div class="content-layout-row">
                 <div class="content-layout layout-item-1">
                       Text #2
                 </div>
                 <div class="layout-cell layout-item-2" >
                     <p>
                      Text #3
                    </p>
                 </div>
            </div>
        </div>
        <div class="content-layout">
             <div class="content-layout-row">
                  <div class="content-layout layout-item-3">
                      <p>Text # 4</p>
                  </div>
             </div>
        </div>
     </div>
<!--Here END the STYLE_2-->
  <?php   } // for i  ?>

您可以为两个单独的div使用不同的类名称,但是如果您想使用它而不更改现有类名称,则可以使用内联CSS。

<?php for ($i = 0; $i < $contador; $i++) { ?>
<!--Here begin the STYLE_1-->
    <div class="content-layout-wrapper layout-item-0" style="margin-bottom: 7px;">
       <div class="content-layout layout-item-1" style=" border-spacing: 10px 0px; border-collapse: separate; ">
         <div class="content-layout-row">
           <div class="layout-cell layout-item-2" style="border-top-style:solid; background: #ffffff;">
             <p> Text #1 </p>
           </div>
         </div>
        </div>
     </div>
    <!--Here END the STYLE_1-->
    <!--Here begin the STYLE_2-->
     <div class="postcontent postcontent-0 clearfix">
        <div class="content-layout-wrapper layout-item-0" style="color: #083752; background: ;  border-collapse: separate;">
            <div class="content-layout-row">
                 <div class="content-layout layout-item-1" style="color: #083752;">
                       Text #2
                 </div>
                 <div class="layout-cell layout-item-2" style"border-style:Double; border-radius: 15px;">
                     <p>
                      Text #3
                    </p>
                 </div>
            </div>
        </div>
        <div class="content-layout">
             <div class="content-layout-row">
                  <div class="content-layout layout-item-3" style="padding-right: 10px;padding-left: 10px;">
                      <p>Text # 4</p>
                  </div>
             </div>
        </div>
     </div>
<!--Here END the STYLE_2-->
  <?php   } // for i  ?>

最新更新