第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何在CSS網(wǎng)格布局中定位特定的列或行?

如何在CSS網(wǎng)格布局中定位特定的列或行?

函數(shù)式編程 2019-08-13 16:56:56
如何在CSS網(wǎng)格布局中定位特定的列或行?是否可以使用CSS選擇特定的網(wǎng)格列或行?例如,假設(shè)我有一個(gè)3行×2列CSS網(wǎng)格布局:grid-template-rows: 1fr 1fr 1fr; grid-template-columns: 1fr 1fr;。如何從第2列中選擇所有元素?例如:( grid:nth-child(column:2)只是我的想法,不是有效的代碼)。我已經(jīng)nth-child在div元素上嘗試了選擇器,但這不允許我在Grid Layout引擎自動(dòng)放置項(xiàng)目時(shí)指定行或列。body {   display: grid;   grid-template-rows: 1fr 1fr 1fr;   grid-template-columns: 1fr 1fr;   grid-gap: 10px;}.item {   background: #999;}<div class="item">   <p>Customer Name</p>   <p>Element 1 | Element 2</p></div><div class="item">   <p>Right Justify</p>   <p>Element 1 | Element 2</p></div><div class="item">   <p>Customer Name</p>   <p>Element 1 | Element 2</p></div><div class="item">   <p>Customer Name</p>   <p>Element 1 | Element 2</p></div><div class="item">   <p>Customer Name</p>   <p>Element 1 | Element 2</p></div><div class="item">   <p>Customer Name</p>   <p>Element 1 | Element 2</p></div><div class="item">   <p>Customer Name</p>   <p>Element 1 | Element 2</p></div>
查看完整描述

3 回答

?
喵喵時(shí)光機(jī)

TA貢獻(xiàn)1846條經(jīng)驗(yàn) 獲得超7個(gè)贊

CSS無法實(shí)現(xiàn)。

CSS以HTML元素,屬性和屬性值為目標(biāo)。

網(wǎng)格列和行沒有這些“鉤子”。

您必須直接定位網(wǎng)格項(xiàng)目。

你寫了:

例如,假設(shè)我有一個(gè)3行×2列CSS網(wǎng)格布局:grid-template-rows: 1fr 1fr 1fr; grid-template-columns: 1fr 1fr;。如何從第2列中選擇所有元素?

grid-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  grid-gap: 10px;
  padding: 10px;
  height: 50vh;
  background-color: gray;}grid-item {
  background-color: lightgreen;}grid-item:nth-child(2n) {
  border: 2px dashed red;}
<grid-container>
  <grid-item></grid-item>
  <grid-item></grid-item>
  <grid-item></grid-item>
  <grid-item></grid-item>
  <grid-item></grid-item>
  <grid-item></grid-item></grid-container>


查看完整回答
反對(duì) 回復(fù) 2019-08-13
?
郎朗坤

TA貢獻(xiàn)1921條經(jīng)驗(yàn) 獲得超9個(gè)贊

如果您想要設(shè)置行的樣式,則應(yīng)用相同的主體。以上為例:

grid-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr 1fr;
  grid-gap: 10px;
  padding: 10px;
  height: 50vh;
  background-color: gray;}grid-item {
  background-color: lightgreen;}grid-item:nth-child(4n+3),grid-item:nth-child(4n) {
  border: 2px dashed red;}
<grid-container>
  <grid-item></grid-item>
  <grid-item></grid-item>
  <grid-item></grid-item>
  <grid-item></grid-item>
  <grid-item></grid-item>
  <grid-item></grid-item>
  <grid-item></grid-item>
  <grid-item></grid-item></grid-container>


查看完整回答
反對(duì) 回復(fù) 2019-08-13
  • 3 回答
  • 0 關(guān)注
  • 875 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)