1. <tfoot id='jSPPF'></tfoot>
        <bdo id='jSPPF'></bdo><ul id='jSPPF'></ul>

    2. <legend id='jSPPF'><style id='jSPPF'><dir id='jSPPF'><q id='jSPPF'></q></dir></style></legend>

      <small id='jSPPF'></small><noframes id='jSPPF'>

        <i id='jSPPF'><tr id='jSPPF'><dt id='jSPPF'><q id='jSPPF'><span id='jSPPF'><b id='jSPPF'><form id='jSPPF'><ins id='jSPPF'></ins><ul id='jSPPF'></ul><sub id='jSPPF'></sub></form><legend id='jSPPF'></legend><bdo id='jSPPF'><pre id='jSPPF'><center id='jSPPF'></center></pre></bdo></b><th id='jSPPF'></th></span></q></dt></tr></i><div id='jSPPF'><tfoot id='jSPPF'></tfoot><dl id='jSPPF'><fieldset id='jSPPF'></fieldset></dl></div>

        如何使用jQuery将两列的高度设置为它们中的最高值?

        时间:2023-09-05

          <bdo id='yJXin'></bdo><ul id='yJXin'></ul>
          <i id='yJXin'><tr id='yJXin'><dt id='yJXin'><q id='yJXin'><span id='yJXin'><b id='yJXin'><form id='yJXin'><ins id='yJXin'></ins><ul id='yJXin'></ul><sub id='yJXin'></sub></form><legend id='yJXin'></legend><bdo id='yJXin'><pre id='yJXin'><center id='yJXin'></center></pre></bdo></b><th id='yJXin'></th></span></q></dt></tr></i><div id='yJXin'><tfoot id='yJXin'></tfoot><dl id='yJXin'><fieldset id='yJXin'></fieldset></dl></div>
            <tbody id='yJXin'></tbody>

              1. <legend id='yJXin'><style id='yJXin'><dir id='yJXin'><q id='yJXin'></q></dir></style></legend>

                  <small id='yJXin'></small><noframes id='yJXin'>

                • <tfoot id='yJXin'></tfoot>
                • 本文介绍了如何使用jQuery将两列的高度设置为它们中的最高值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  sheetdb 插件从共享的 googlesheet 中提取数据以在 WordPress 网站上显示它们.该页面只显示来自 googlesheet 的动态内容.这是一个简单的页面.以下是来自 WordPress 页面编辑器的自定义字段内容.这是通过模板在页面上打印数据的(代码添加在本文末尾)

                  [sheetdb url="https://sheetdb.io/api/v1/ymk583vab4dwh"搜索=批准=1&amp;显示=1"]<div 类=故事条目"><div 类=内容">{{故事}} </div><div class=contestent-name">-{{First Name}} {{Initial}}</div></div>[/sheetdb]

                  页面上显示列的 div 的 CSS.

                  .story-entry {边距:15px 10px;边框:纯色 1px 黑色;填充:10px 20px;宽度:计算(50% - 22px);向左飘浮;}<?php $story = get_field('story');?><div class=比赛故事"><div 类=wrap-x"><div 类=内部"><div 类=行"><div class="contest-story-text col col-xs-12"><?php echo do_shortcode($story);?></div></div></div></div></div>

                  列的问题是它们具有相同的高度,从而导致不必要的额外空间浪费.我得到了动态找出两列的最大高度并将它们都设置为最大高度的逻辑.

                  我尝试使用下面的 jQuery 代码来设置两列的高度.

                  $(document).ready(function() {变量最大高度 = 0;var entryNumber = 1;var prevEntrySelector = null;$(".story-entry").each(function(){警报(你好");if ($(this).height() > maxHeight) { maxHeight = $(this).height();}if ((entryNumber % 2) == 0) {//偶数入口.//设置前一个条目和这个条目的高度为 maxHeight.$(this).height(maxHeight);prevEntrySelector.height(maxHeight);//this - 这个选择器 - 这个故事条目最大高度 = 0;}prevEntrySelector = $(this);入口编号 ++;});$(".entry-selector").height(maxHeight);});

                  此代码不适用于

                  这是我的页面想要使用 jQuery 看起来像 this.

                  此页面的完整模板代码:

                  解决方案

                  你可以用css做只需添加这些行

                  .contest-story-text >分区{显示:弯曲;弹性方向:行;弹性包装:换行;宽度:100%;}.story-entry {高度:自动!重要;}@media only screen and (max-width: 600px) {.story-entry {宽度:计算(100% - 22px)!重要}}

                  A sheetdb plugin pulls data from a shared googlesheet to display them on a WordPress site. The page displays nothing else but this dynamic contents from the googlesheet. It is a simple page. Below is custom field content from WordPress page editor. This is what prints data on the page via template(Code added at the end of this post)

                  [sheetdb url="https://sheetdb.io/api/v1/ymk583vab4dwh" search="Approval=1&amp;Display=1"]
                  <div class="story-entry">
                    <div class="content"> {{Story}} </div>
                    <div class="contestent-name">-{{First Name}} {{Initial}}</div>
                  </div>
                  [/sheetdb]
                  

                  CSS for the div displaying columns on the page.

                  .story-entry {
                    margin: 15px 10px;
                    border: solid 1px black;
                    padding: 10px 20px;
                    width: calc(50% - 22px);
                    float: left;
                  }
                  
                  <?php $story = get_field('story'); ?>
                  
                  <div class="contest-story">
                    <div class="wrap-x">
                      <div class="inside">
                        <div class="row">
                          <div class="contest-story-text col col-xs-12"><?php echo do_shortcode($story); ?></div>  
                        </div>
                      </div>
                    </div>
                  </div>
                  

                  The problem with the columns is them having the same height resulting in unnecessary wastage of the extra space. I got the logic to dynamically find out the max height of the two columns and set both them to the max height.

                  With the following jQuery code I am trying to use to set the height to both the columns.

                  $(document).ready(function() {
                      var maxHeight = 0;
                      var entryNumber = 1;
                      var prevEntrySelector = null;
                      $(".story-entry").each(function(){
                      alert('Hello');
                         if ($(this).height() > maxHeight) { maxHeight = $(this).height(); }
                         if ((entryNumber % 2) == 0) {
                        // Even entry.
                        // Set height of previous entry and this entry to maxHeight.
                        $(this).height(maxHeight);
                        prevEntrySelector.height(maxHeight);
                        // this - this selector - this story entry
                        maxHeight = 0;
                         }
                         prevEntrySelector = $(this);
                         entryNumber ++;
                      });
                  
                      $(".entry-selector").height(maxHeight);
                  });
                  

                  This code doesn't work on this page. Below is the reference page.

                  https://knackshops.com/pages/spread-joy-message

                  What I did so far is as seen below with unnecessary space after the content

                  This is the page that I want to make look like this with jQuery.

                  The full template code for this page:

                  <?php 
                  $hero = get_field('hero');
                  $hero_h1 = $hero['hero_-_h1'];
                  $hero_h2 = $hero['hero_-_h2'];
                  $background = $hero['hero_-_background_options'];
                  $image = $background['background_-_image'];
                  
                  $link_text = get_field('link_text');
                  $link_to_contest = get_field('link_to_contest');
                  
                  $story = get_field('story');
                  ?>
                  
                  <?php get_header(); ?>
                  
                  <div class="default-flex-hero relative">
                    <div class="inside">
                      <div class="row mb0 pt pb">
                      <?php if($image): ?>
                        <div class="col col-xs-12 col-md-2 col-lg-2 mb0">
                            <picture>
                              <source media="(max-width: 480px)" srcset="<?php echo($image['sizes']['small']); ?>">
                              <source media="(max-width: 1024px)" srcset="<?php echo($image['sizes']['medium']); ?>">
                              <source media="(max-width: 1280px)" srcset="<?php echo($image['sizes']['large']); ?>">
                              <source srcset="<?php echo($image['sizes']['xlarge']); ?>">
                              <img src="<?php echo($image['sizes']['xlarge']); ?>" alt="<?php echo $image['alt']; ?>" />
                            </picture>
                          </div>
                        <?php endif; ?>
                        <div class="hero-col col col-xs-12 col-md-10 col-lg-10 mb0">
                                <h1 class="mb0 color-tan-dark">
                                  <?php if( $hero_h1 ): echo $hero_h1; endif; ?>
                                </h1>
                                <?php if( $hero_h2 ): ?>
                                <h2 class="mb0 mt2 alt-heading h4">
                                  <?php echo $hero_h2; ?>
                                </h2>
                                <?php endif; ?>
                          </div>
                      </div>
                    </div>
                  </div>
                  
                  <div class="contest-link">
                    <div class="wrap-x">
                      <div class="inside">
                        <div class="row">
                          <div class="contest-link-text col col-xs-12">
                          SHARE YOUR OWN STORY <a href="<?php echo $link_to_contest; ?>">HERE</a>
                          </div>  
                        </div>
                      </div>
                    </div>
                  </div>
                  
                  **<div class="contest-story">
                    <div class="wrap-x">
                      <div class="inside">
                        <div class="row">
                          <div class="contest-story-text col col-xs-12"><?php echo do_shortcode($story); ?></div>  
                        </div>
                      </div>
                    </div>
                  </div>**
                  
                  <?php get_footer(); ?>
                  

                  解决方案

                  You can do with css just add these line

                  .contest-story-text > div{
                      display: flex;
                      flex-direction: row;
                      flex-wrap: wrap;
                      width: 100%;
                  }
                  
                  .story-entry {
                      height: auto !important;
                  }
                  
                  @media only screen and (max-width: 600px) {
                      .story-entry {
                              width: calc(100% - 22px) !important
                      }
                  }
                  

                  这篇关于如何使用jQuery将两列的高度设置为它们中的最高值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                    1. <tfoot id='0pf1f'></tfoot>

                          <tbody id='0pf1f'></tbody>
                        <legend id='0pf1f'><style id='0pf1f'><dir id='0pf1f'><q id='0pf1f'></q></dir></style></legend>

                      1. <i id='0pf1f'><tr id='0pf1f'><dt id='0pf1f'><q id='0pf1f'><span id='0pf1f'><b id='0pf1f'><form id='0pf1f'><ins id='0pf1f'></ins><ul id='0pf1f'></ul><sub id='0pf1f'></sub></form><legend id='0pf1f'></legend><bdo id='0pf1f'><pre id='0pf1f'><center id='0pf1f'></center></pre></bdo></b><th id='0pf1f'></th></span></q></dt></tr></i><div id='0pf1f'><tfoot id='0pf1f'></tfoot><dl id='0pf1f'><fieldset id='0pf1f'></fieldset></dl></div>

                        <small id='0pf1f'></small><noframes id='0pf1f'>

                          <bdo id='0pf1f'></bdo><ul id='0pf1f'></ul>