不循环环绕

时间:2017-10-10 07:46:26

标签: php html

我在一个页面上有两个部分。你可以在这里看到它:http://www.equitasmg.com/who-we-are-2/

这两个部分都有一个<div>,但第一部分“我们的领导”似乎与<div>不一样。 <div>包围了该部分中的第一个项目,但没有包裹所有项目。

以下是两个部分的PHP。

第一部分

 <center><h2>Our Leadership</h2></center>
 <center><div>
 <?php
 $people= get_field('people');
 $a=0;
 foreach ($people as $r) {
$a++;
?>
          <div class="people">
            <img src="<?php echo $r['image']['sizes']['team'];?>" style="max-width:750px !important;width:100%;">
            <h3>
                <?php echo $r['name'];?>
            </h3>
            <div class="position">
                <h4><?php echo $r['position'];?></h4>
            </div>
            <?php echo $r['intro_text'];?>
            <?php if ($r[ 'learn_more_text']) { ?>
            <a href="#" class="button" data-reveal-id="<?php echo sanitize_title($r['name'] );?>">Learn More</a>
            <?php } ?>
 <?php if ($r[ 'learn_more_text']) { ?>
 <div id="<?php echo sanitize_title($r['name'] );?>" class="reveal-modal medium" data-reveal aria-labelledby="modalTitle" aria-hidden="true" role="dialog">

<h3><?php echo $r['name'];?></h3>
<div class="position">
    <?php echo $r['position'];?>
</div>
<div class="content">       
<?php echo $r['learn_more_text'];?>
</div>
<a class="close-reveal-modal" aria-label="Close">&#215;</a>
 </div>
        </div>
 <?php } ?>
 </div>
 <?php } ?>
 </div></center>
 <div style="clear:both;"></div>

第二部分

 <center><h2>Our Team</h2></center>
 <center><div>
 <?php
 $people2= get_field('people_bottomsection');
 $a=0;
 foreach ($people2 as $r) {
$a++;
?>
          <div class="people">
            <img src="<?php echo $r['image']['sizes']['team'];?>" style="max-width:750px !important;width:100%;">
            <h3>
                <?php echo $r['name'];?>
            </h3>
            <div class="position">
                <h4><?php echo $r['position'];?></h4>
            </div>
            <?php echo $r['intro_text'];?>
            <?php if ($r[ 'learn_more_text']) { ?>
            <a href="#" class="button" data-reveal-id="<?php echo sanitize_title($r['name'] );?>">Learn More</a>
            <?php } ?>
 <?php if ($r[ 'learn_more_text']) { ?>
 <div id="<?php echo sanitize_title($r['name'] );?>" class="reveal-modal medium" data-reveal aria-labelledby="modalTitle" aria-hidden="true" role="dialog">

<h3><?php echo $r['name'];?></h3>
<div class="position">
    <?php echo $r['position'];?>
</div>
<div class="content">       
<?php echo $r['learn_more_text'];?>
</div>
<a class="close-reveal-modal" aria-label="Close">&#215;</a>
 </div>
        </div>
 <?php } ?>
 </div>
 <?php } ?>
 </div></center>
 <div style="clear:both;"></div>

1 个答案:

答案 0 :(得分:0)

你只需要额外的div。

第一部分你在这里得到了额外的div

<center><h2>Our Leadership</h2></center>
<center>
<div>
<?php
$people= get_field('people');
$a=0;
foreach ($people as $r) {
$a++;
?>
<div class="people">
<img src="<?php echo $r['image']['sizes']['team'];?>" style="max-width:750px !important;width:100%;">
<h3>
<?php echo $r['name'];?>
</h3>
<div class="position">
<h4><?php echo $r['position'];?></h4>
</div>
<?php echo $r['intro_text'];?>
<?php if ($r[ 'learn_more_text']) { ?>
<a href="#" class="button" data-reveal-id="<?php echo sanitize_title($r['name'] );?>">Learn More</a>
<?php } ?>
<?php if ($r[ 'learn_more_text']) { ?>
<div id="<?php echo sanitize_title($r['name'] );?>" class="reveal-modal medium" data-reveal aria-labelledby="modalTitle" aria-hidden="true" role="dialog">

	<h3><?php echo $r['name'];?></h3>
	<div class="position">
	<?php echo $r['position'];?>
	</div>
	<div class="content">       
	<?php echo $r['learn_more_text'];?>
	</div>
	<a class="close-reveal-modal" aria-label="Close">&#215;</a>
</div>
<!-- </div> --> //extra div here
<?php } ?>
</div>
<?php } ?> //end of foreach
</div>
</center>
<div style="clear:both;"></div>

第二部分

<center><h2>Our Team</h2></center>
<center>
	<div>
	<?php
	$people2= get_field('people_bottomsection');
	$a=0;
	foreach ($people2 as $r) {
	$a++;
	?>
		<div class="people">
			<img src="<?php echo $r['image']['sizes']['team'];?>" style="max-width:750px !important;width:100%;">
			<h3>
			<?php echo $r['name'];?>
			</h3>
			<div class="position">
			<h4><?php echo $r['position'];?></h4>
			</div>
		<?php echo $r['intro_text'];?>
		<?php if ($r[ 'learn_more_text']) { ?>
		<a href="#" class="button" data-reveal-id="<?php echo sanitize_title($r['name'] );?>">Learn More</a>
		<?php } ?>
		<?php if ($r[ 'learn_more_text']) { ?>
			<div id="<?php echo sanitize_title($r['name'] );?>" class="reveal-modal medium" data-reveal aria-labelledby="modalTitle" aria-hidden="true" role="dialog">

				<h3><?php echo $r['name'];?></h3>
				<div class="position">
				<?php echo $r['position'];?>
				</div>
				<div class="content">       
				<?php echo $r['learn_more_text'];?>
				</div>
			<a class="close-reveal-modal" aria-label="Close">&#215;</a>
			</div>
		<!-- </div> --> //extra div 
		<?php } ?>
		</div>
	<?php } ?>
	</div>
</center>