英文:
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 -->
<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>
<!-- 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 </div>
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 -->
<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>
<!-- end snippet -->
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论