在一个具有两个内部列的列末添加一句话。

huangapple go评论60阅读模式
英文:

add a sentence at the end of a column that itself has two inner-column

问题

Sure, here is the translated part:

我尝试在最后一列添加了两行,第一行分成了两列,第二行没有,但没有成功。我期望在第三列的末尾添加一行,其中包含一个句子。

英文:

Can you help me know how to add a sentence to the end of the third column? the third column itself has two inner-column but I wanna add the sentence at the end of the third column with its full width, not one of the inner columns. I think it should be simple but I can't find a way that works.

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

.main-container {
  display: grid;
  grid-template-columns: 3fr 4fr 5fr;
  margin: auto;
  padding-inline-start: 100px;
  padding-inline-end: 74px;
  gap: 82px;
}

.column:last-child {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
}

<!-- language: lang-html -->

&lt;div class=&quot;main-container&quot;&gt;
  &lt;div class=&quot;column&quot;&gt;
    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
    eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
    enim ad minim veniam, quis nostrud exercitation ullamco laboris
    nisi ut aliquip ex ea commodo consequat.
  &lt;/div&gt;
  &lt;div class=&quot;column&quot;&gt;
    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
    eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
    enim ad minim veniam, quis nostrud exercitation ullamco laboris
    nisi ut aliquip ex ea commodo consequat.
  &lt;/div&gt;

  &lt;div class=&quot;column&quot;&gt;
    &lt;div class=&quot;inner-column&quot;&gt;
      &lt;h2 class=&quot;fh22&quot;&gt;Quick Access&lt;/h2&gt;
      &lt;Link to=&quot;/pages/Home&quot; class=&quot;fqaccess fhome&quot;&gt;
      Home
      &lt;/Link&gt;
    &lt;/div&gt;
    &lt;div class=&quot;inner-column&quot;&gt;
      &lt;h2 class=&quot;fh22&quot;&gt;Helpful Links&lt;/h2&gt;
      &lt;a href=&quot;#&quot; class=&quot;fqaccess fhome&quot;&gt;
        Link 1
      &lt;/a&gt;
    &lt;/div&gt;

  &lt;/div&gt;

<!-- end snippet -->

I tried to add two rows to the last column, first divided to two columns and second not, but it didn't work. I expected it cause a row at the end of the third main column to have a sentence in.

答案1

得分: 0

你正在使用两列网格布局来为第三列布局,所以需要使底部内容的包含元素跨越两列,使用 grid-column: span 2

(你还缺少一个 </div> 标签。)

.main-container {
  display: grid;
  grid-template-columns: 3fr 4fr 5fr;
  margin: auto;
  padding-inline-start: 100px;
  padding-inline-end: 74px;
  gap: 82px;
}

.column:last-child {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
}

.bottom {grid-column: span 2}
<div class="main-container">
  <div class="column">
    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
    eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
    enim ad minim veniam, quis nostrud exercitation ullamco laboris
    nisi ut aliquip ex ea commodo consequat.
  </div>
  <div class="column">
    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
    eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
    enim ad minim veniam, quis nostrud exercitation ullamco laboris
    nisi ut aliquip ex ea commodo consequat.
  </div>
  <div class="column">
    <div class="inner-column">
      <h2 class="fh22">Quick Access</h2>
      <Link to="/pages/Home" class="fqaccess fhome">
        Home
      </Link>
    </div>
    <div class="inner-column">
      <h2 class="fh22">Helpful Links</h2>
      <a href="#" class="fqaccess fhome">
        Link 1
      </a>
    </div>
    <div class="bottom">
      This text spans both columns
    </div>
  </div>
</div>
英文:

You are using a two-column grid layout for the third column, so you need to have the containing element of the bottom content span both columns with grid-column: span 2.

(You are also missing a &lt;/div&gt; tag.)

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

.main-container {
  display: grid;
  grid-template-columns: 3fr 4fr 5fr;
  margin: auto;
  padding-inline-start: 100px;
  padding-inline-end: 74px;
  gap: 82px;
}

.column:last-child {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
}

.bottom {grid-column: span 2}

<!-- language: lang-html -->

&lt;div class=&quot;main-container&quot;&gt;
  &lt;div class=&quot;column&quot;&gt;
   Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
              eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
              enim ad minim veniam, quis nostrud exercitation ullamco laboris
              nisi ut aliquip ex ea commodo consequat.
  &lt;/div&gt;
  &lt;div class=&quot;column&quot;&gt;
    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
              eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
              enim ad minim veniam, quis nostrud exercitation ullamco laboris
              nisi ut aliquip ex ea commodo consequat.
  &lt;/div&gt;
  &lt;div class=&quot;column&quot;&gt;
    &lt;div class=&quot;inner-column&quot;&gt;
      &lt;h2 class=&quot;fh22&quot;&gt;Quick Access&lt;/h2&gt;
      &lt;Link to=&quot;/pages/Home&quot; class=&quot;fqaccess fhome&quot;&gt;
        Home
      &lt;/Link&gt;
    &lt;/div&gt;
    &lt;div class=&quot;inner-column&quot;&gt;
      &lt;h2 class=&quot;fh22&quot;&gt;Helpful Links&lt;/h2&gt;
      &lt;a href=&quot;#&quot; class=&quot;fqaccess fhome&quot;&gt;
        Link 1
      &lt;/a&gt;
    &lt;/div&gt;
    &lt;div class=&quot;bottom&quot;&gt;
      This text spans both columns
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

<!-- end snippet -->

huangapple
  • 本文由 发表于 2023年5月15日 06:05:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/76249872.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定