如何编辑php使图像显示在屏幕的左手

gpfsuwkq  于 2023-09-29  发布在  PHP
关注(0)|答案(2)|浏览(104)

我对php知之甚少,也几乎不懂bootstrap,但我正在尝试更新一个wordpress模板,以调整图片在页面上的显示位置。该网站使用高级自定义字段插件,以便能够在整个网站中使用相同的框架。php使用这些字段并添加循环和if语句来更改图像在页面的哪一侧。This是我正在调整的模板的网页。
我正试图使蓝色“服务”部分中的图像显示在左侧而不是右侧。这是该部分的php:

<?php get_template_part('waves/blue', 'top-one'); ?>
        <div id="about-wrapper" class="wrapper">
        
           <div class="wrapper">
            <div class="<?php echo esc_attr( $container ); ?> back-forth-text-image">
                <?php $sections = get_field('lirtb_sections'); ?>
                <?php $numOfRows = count($sections) - 1; ?>

                <?php foreach($sections as $skey=>$section){ ?>
                    <div class="row <?php echo($skey < $numOfRows ? 'margin-bottom-double sm-margin-bottom-half' : '') ?>">
                        <div class="col-12 col-md-6 <?php echo ($skey % 2 != 0 ? 'pl-5' : '')?>  bft-text padding-right-half">
                            <div class="bft-text-container">
                                <h6 class="sans-serif font-weight-bold emphasis no-margin"><?php echo $section['lirtb_title'] ?></h6>
                                <h3 class="h2"><?php echo $section['lirtb_header']?></h3>
                                <div class="first-p margin-bottom-half">
                                    <?php echo $section['lirtb_text']?>
                                </div>
                                <?php if(
                                        isset($section['lirtb_button_text']) &&
                                         !empty($section['lirtb_button_text']) &&
                                         isset($section['lirtb_link']) &&
                                         !empty($section['lirtb_link'])){?>
                                <a href="<?php echo $section['lirtb_link'] ?>" type="button" class="btn transparent"><?php echo $section['lirtb_button_text'] ?></a>
                                <?php } ?>
                            </div>
                        </div>

                        <div class="col-12 col-md-6  bft-image sm-margin-bottom-quarter">
                        <div class="row">
                            <img src="<?php echo $section['lirtb_image']['url']?>" />
                        </div>  
                        <div class="row">
                            <img src="<?php echo $section['lirtb2_image']['url']?>" />
                        </div>
                        </div>
                    </div>
                <?php } ?>
            </div>
        </div>
        </div>
        <?php get_template_part('waves/blue', 'bottom-one'); ?>

我不需要循环,因为它只是一个部分,在与蓝色背景,所以我试图把循环了,事情只是从那里去了侧面的方式…提前感谢!

jc3wubiy

jc3wubiy1#

只需将.order-first类添加到包含图像的第二列div,就会在父行中首先显示列。
不确定你是否可以通过你的ACF构建器安全地实现这一点。
参见下面的工作示例...

#about-wrapper {
  background: #c5dbf2;
  min-height: 400px;
  width: 100%;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">

<div class="wave-wrapper"><svg version="1.1" id="" class="sfg-wave top" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1440 100" style="enable-background:new 0 0 1440 100" xml:space="preserve"><style type="text/css">.st2{fill:#c5dbf2}.wave-2,.wave-3,.wave-4{visibility:hidden}</style><path transform="scale(-1, -1) translate(-1440, -100)" id="" class="st2 wave-1" fill="#c5dbf2" fill-rule="evenodd" d="M0 0h1440c-296.556 8-565.33 24.052-806.323 48.155C392.685 72.258 181.46 56.206 0 0z"></path></svg></div>

<div id="about-wrapper" class="wrapper">
  <div class="wrapper py-4">
    <div class="container-md container-fluid back-forth-text-image">
      <div class="row align-items-center">
        <div class="col-12 col-sm-6 bft-text padding-right-half">
          <div class="bft-text-container">
            <h6 class="sans-serif font-weight-bold emphasis no-margin"></h6>
            <h3 class="h2">Lorem Ipsum</h3>
            <div class="first-p margin-bottom-half">
              <p>Sed nec justo a velit ultrices laoreet eget nec justo:</p>
              <ul>
                <li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;"><a href="#">Vivamus eu ligula eget nisi accumsan bibendum</a>,  elit eget volutpat dignissim, dolor mi eleifend justo.</span></li>
                <li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;"><a href="#">Nulla facilisi</a> vel fringilla nulla sem eu justo volutpat.</span></li>
                <li style="font-weight: 400;" aria-level="1"><a href="#"><span style="font-weight: 400;">In et hendrerit sapien</span></a></li>
              </ul>
              <p><span style="font-weight: 400;">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed auctor, lorem eu ultricies vehicula, urna nulla consequat justo, in varius libero lacus ut arcu. Nunc vitae elit et odio dignissim facilisis.</span></p>
            </div>
          </div>
        </div>
        <div class="col-12 col-sm-6 bft-image sm-margin-bottom-quarter order-first">
          <div class="row">
            <img src="https://i.imgur.com/nRB5xz4.png" class="img-fluid entered lazyloaded"><noscript><img src="https://i.imgur.com/nRB5xz4.png" /></noscript>
          </div>
          <div class="row">
            <img src="">
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

<div class="wave-wrapper"><svg version="1.1" id="" class="sfg-wave bottom" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1440 100" style="enable-background:new 0 0 1440 100; margin-bottom: 20px;" xml:space="preserve"><style type="text/css">.st3{fill:#c5dbf2}.wave-2,.wave-3,.wave-4{visibility:hidden}</style><path id="" class="st3 wave-1" fill="#c5dbf2" fill-rule="evenodd" d="M0 0h1440v31.065c-461.292-14.26-805.86.525-1033.703 44.355C178.454 119.249 43.021 104.464 0 31.065V0z"></path></svg></div>
cgvd09ve

cgvd09ve2#

最好使用CSS来进行这种更改,但只需更改保存图像的div的位置,您就可以首先显示它们,如下面的代码。另外,不要删除“foreach”,它处理数据库中的数据。

<?php get_template_part('waves/blue', 'top-one'); ?>
        <div id="about-wrapper" class="wrapper">
        
           <div class="wrapper">
            <div class="<?php echo esc_attr( $container ); ?> back-forth-text-image">
                <?php $sections = get_field('lirtb_sections'); ?>
                <?php $numOfRows = count($sections) - 1; ?>

                <?php foreach($sections as $skey=>$section){ ?>
                    <div class="row <?php echo($skey < $numOfRows ? 'margin-bottom-double sm-margin-bottom-half' : '') ?>">
                        <div class="col-12 col-md-6  bft-image sm-margin-bottom-quarter">
                        <div class="row">
                            <img src="<?php echo $section['lirtb_image']['url']?>" />
                        </div>  
                        <div class="row">
                            <img src="<?php echo $section['lirtb2_image']['url']?>" />
                        </div>
                        </div>
                        <div class="col-12 col-md-6 <?php echo ($skey % 2 != 0 ? 'pl-5' : '')?>  bft-text padding-right-half">
                            <div class="bft-text-container">
                                <h6 class="sans-serif font-weight-bold emphasis no-margin"><?php echo $section['lirtb_title'] ?></h6>
                                <h3 class="h2"><?php echo $section['lirtb_header']?></h3>
                                <div class="first-p margin-bottom-half">
                                    <?php echo $section['lirtb_text']?>
                                </div>
                                <?php if(
                                        isset($section['lirtb_button_text']) &&
                                         !empty($section['lirtb_button_text']) &&
                                         isset($section['lirtb_link']) &&
                                         !empty($section['lirtb_link'])){?>
                                <a href="<?php echo $section['lirtb_link'] ?>" type="button" class="btn transparent"><?php echo $section['lirtb_button_text'] ?></a>
                                <?php } ?>
                            </div>
                        </div>
                    </div>
                <?php } ?>
            </div>
        </div>
        </div>
        <?php get_template_part('waves/blue', 'bottom-one'); ?>

相关问题