css-grid 相关问题

CSS Grid Layout是一种允许创建网格的W3C技术。它不需要使用浮动,表格,绝对定位甚至flexbox(另一种CSS3技术)来构建各种网格,从简单到复杂。一般情况下,请勿将此标记用于CSS网格系统。

和 不包装在CSS网格布局中>> 我正在尝试了解CSS网格布局,到目前为止,我喜欢它的每一点!但是,我似乎无法使代码发挥作用。 当导航侧边栏填充整个宽度时,我希望右侧的段落在导航下方分解。我知道我将如何使用flexbox和媒体查询(flex-direction:行还是列)做到这一点,但是我真的不知道如何使用CSS网格做到这一点。你能帮我吗? .container { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); grid-gap: 25px; } /* Navigation */ .legal-navi { grid-column: 1; list-style: none; padding: 0; font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif; } .legal-navi li { width: 100%; box-sizing: border-box; /* border */ border: black solid; border-width: 1px 0 0 0; transition: background-color .4s; } .legal-navi li:hover { background-color: #FCFDD5; } .legal-navi li a { box-sizing: border-box; width: 100%; height: 100%; padding: 20px; display: block; text-decoration: inherit; color: inherit; transition: transform .4s; transition-timing-function: ease-out; } .legal-navi li a:hover { transform: translateX(9px); } .legal-navi li:last-child { border-width: 1px 0 1px 0; } /* content */ .legal-content { grid-column: 2 / -1; } <div class="container"> <ul class="legal-navi"> <li> <a href="lorem">Lorem</a> </li> <li> <a href="ipsum">Ipsum</a> </li> <li> <a href="dolor">Dolor</a> </li> <li> <a href="ahmet">Ahmet</a> </li> </ul> <p class="legal-content"> Cry louder at reflection eat half my food and ask for more so dont wait for the storm to pass, dance in the rain for tweeting a baseball poop on floor and watch human clean up lick the plastic bag but stand with legs in litter box, but poop outside. Stand with legs in litter box, but poop outside cats are fats i like to pets them they like to meow back, twitch tail in permanent irritation so immediately regret falling into bathtub yet nyan fluffness ahh cucumber!, but the door is opening! how exciting oh, it's you, meh purr while eating. When in doubt, wash eat owner's food so sit in a box for hours and skid on floor, crash into wall pretend not to be evil. Give attitude if human is on laptop sit on the keyboard so demand to have some of whatever the human is cooking, then sniff the offering and walk away, cat slap dog in face. Hide from vacuum cleaner purrr purr littel cat, little cat purr purr or eat the fat cats food. Eat an easter feather as if it were a bird then burp victoriously, but tender pee in human's bed until he cleans the litter box sleep in the bathroom sink sleep nap but furrier and even more furrier hairball cat gets stuck in tree firefighters try to get cat down firefighters get stuck in tree cat eats firefighters' slippers. Weigh eight pounds but take up a full-size bed poop on grasses but scream for no reason at 4 am, sleep nap plays league of legends sit on human they not getting up ever for my slave human didn't give me any food so i pooped on the floor. Meow. Meow for food, then when human fills food dish, take a few bites of food and continue meowing cat fur is the new black cat fur is the new black , cough hairball, eat toilet paper grab pompom in mouth and put in water dish for stare out cat door then go back inside i love cats i am one wake up scratch humans leg for food then purr then i have a and relax. Annoy kitten brother with poking. Curl up and sleep on the freshly laundered towels eat too much then proceed to regurgitate all over living room carpet while humans eat dinner, for sit on human sleep everywhere, but not in my bed i show my fluffy belly but it's a trap! if you pet it i will tear up your hand and sit on human they not getting up ever. Mewl for food at 4am x intently sniff hand cat milk copy park pee walk owner escape bored tired cage droppings sick vet vomit but show belly nyan fluffness ahh cucumber! so you call this cat food. Meowing chowing and wowing then cats take over the world for chase ball of string for being gorgeous with belly side up. Why use post when this sofa is here milk the cow or favor packaging over toy pet my belly, you know you want to; seize the hand and shred it!. Sniff sniff chew on cable stare at owner accusingly then wink for eat the rubberband, asdflkjaertvlkjasntvkjn (sits on keyboard) the door is opening! how exciting oh, it's you, meh. Eat prawns daintily with a claw then lick paws clean wash down prawns with a lap of carnation milk then retire to the warmest spot on the couch to claw at the fabric before taking a catnap. Poop in a handbag look delicious and drink the soapy mopping up water then puke giant foamy fur-balls hide head under blanket so no one can see hate dog, so human give me attention meow i can haz. Behind the couch climb leg, so sun bathe. Ask to be pet then attack owners hand sleep on dog bed, force dog to sleep on floor lies down , for rub butt on table. Mew chase ball of string so scratch at fleas, meow until belly rubs, hide behind curtain when vacuum cleaner is on scratch strangers and poo on owners food, yet intently stare at the same spot, yet plays league of legends mesmerizing birds for cat jumps and falls onto the couch purrs and wakes up in a new dimension filled with kitty litter meow meow yummy there is a bunch of cats hanging around eating catnip . Scratch at fleas, meow until belly rubs, hide behind curtain when vacuum cleaner is on scratch strangers and poo on owners food my left donut is missing, as is my right but give me some of your food give me some of your food give me some of your food meh, i don't want it i is not fat, i is fluffy, but i like big cats and i can not lie, but lick face hiss at owner, pee a lot, and meow repeatedly scratch at fence purrrrrr eat muffins and poutine until owner comes back. Lick sellotape find empty spot in cupboard and sleep all day destroy the blinds and stare at owner accusingly then wink ccccccccccccaaaaaaaaaaaaaaatttttttttttttttttssssssssssssssss but kitty pounce, trip, faceplant you didn't see that no you didn't definitely didn't lick, lick, lick, and preen away the embarrassment for mesmerizing birds. Shove bum in owner's face like camera lens Gate keepers of hell or i heard this rumor where the humans are our owners, pfft, what do they know?!. </p> </div> 我正在尝试了解CSS网格布局,到目前为止,我喜欢它的每一点!但是,我似乎无法使代码发挥作用。当导航侧边栏填充整个宽度时,我希望该段落... 我想您可以看看如何在引导程序中解决它。侧栏根本不会展开。查看它们的组成以及何时使用类: 容器此类应具有动态宽度,具体取决于@mediaquery设置。 行您还需要做一些事情以分隔线。阅读行类的工作原理。 通常,引导程序文档本身是指以下页面:https://css-tricks.com/snippets/css/a-guide-to-flexbox/#flexbox-background 在纯CSS上有关于这个主题的解释-这可能就是您的意思... 带有已使用mediaquery的网格示例 <style> .left, .right { float: left; width: 20%; /* The width is 20%, by default */ } .main { float: left; width: 60%; /* The width is 60%, by default */ } /* Use a media query to add a breakpoint at 800px: */ @media screen and (max-width: 800px) { .left, .main, .right { width: 100%; /* The width is 100%, when the viewport is 800px or smaller */ } } </style>

我正在尝试了解CSS网格布局,到目前为止,我喜欢它的每一点!但是,我似乎无法使代码发挥作用。当导航侧边栏填充整个宽度时,我希望该段落...

回答 1 投票 0

动态CSS Grid列可能带有可选的页眉或页脚行

借助CSS Grid,动态列数很容易。 grid-template-columns:repeat(auto-fit,minmax(100px,1fr)); //这些.cell布局很好 [[ ]]

回答 1 投票 0

网格扩展网格中的其他元素

我面临的一个问题是,扩展(添加更多内容以便拉伸)网格中的一项会扩展所有其他项,即使其他项没有多余的内容会要求它们拉伸...

回答 1 投票 0


我可以使用纯CSS将自动填充网格居中吗?

我正在尝试用尽可能多的块水平填充我的页面并将结果居中。我希望当窗口变小时能够调整网格大小:宽窗口xxx小窗口xx ...

回答 2 投票 -1

如何在CSS中保持相同尺寸的同时放大图像

我知道,当您在包装图像的div中使用overflow:hidden时,尺寸将保持不变。但是我不确定如何使用flex项目。我尝试将div添加到每个...的外部...

回答 1 投票 0

为什么网格项没有移到末尾?

我正在尝试将“ Contact”一词发送到表格的末尾,但它似乎完全没有移动。我是使用CSS Grid属性的新手,所以我不确定自己在做什么错。我有一个用于...

回答 2 投票 2

为什么不将span元素设置为使用CSSGrid结束?

我正在尝试将“ Contact”一词发送到表格的末尾,但它似乎完全没有移动。我是使用CSSGrid属性的新手,所以我不确定自己在做什么错。我有一个所有的网格容器...

回答 1 投票 0

如何在CSS网格中为“ 1fr”指定宽度和高度?

我有一个非常复杂的残缺布局,我正在尝试使用CSS网格实现,这是我的列和行布局的代码:grid-template-columns:8fr 1fr 3fr 8fr 1fr 5fr 2fr 6fr; grid -...

回答 2 投票 0

CSS网格中的居中正方形

我正在尝试创建四个以正方形模式显示的均匀间隔的正方形(两个在顶部,两个在底部),并在页面上居中,就像这样:我试图在css网格中执行此操作,但是当.. 。

回答 1 投票 0

当没有列时删除网格间隙

我有一部分的html需要以某种方式显示,但是某些元素可能是可选的,我不确定是否可以使用display:grid来显示。我需要3列,但第一列和...

回答 1 投票 0

为什么我的CSS网格行相互折叠?

我正在使用CSS Grid Layout替换HTML表结构。我有两个带有多行的网格模板列和网格模板区域。所有行似乎都被彼此覆盖。什么...

回答 2 投票 0

CSS网格-表格行相互重叠书写

我正在使用CSSGrid替换HTML表结构。我有两个带有多行的网格模板列和网格模板区域。所有行似乎都被彼此覆盖。我有什么...

回答 2 投票 0

CSS网格-所有行都彼此叠加

我正在使用CSSGrid替换HTML表结构。我有两个带有多行的网格模板列和网格模板区域。所有行似乎都被彼此覆盖。我有什么...

回答 1 投票 0

两列相等的宽度(其中宽度由最长的一列设置,而第三列填充剩余的空间

我想使用CSS Grid进行这样的布局,但有其他可能性:基本上,我想拥有一个包含3个元素(输入,btn1,btn2)的容器.grid。首先,btn1 ...

回答 2 投票 5

等宽列,其中宽度由最长的一列设置

我想使用CSS Grid进行这样的布局,但有其他可能性:基本上,我想拥有一个包含3个元素(输入,btn1,btn2)的容器.grid。首先,btn1 ...

回答 2 投票 5

网格布局允许2个元素具有相等的宽度(适合最长的内容),其余元素占据其余部分?

我想使用CSS Grid进行这样的布局,但有其他可能性:基本上,我想拥有一个包含3个元素(输入,btn1,btn2)的容器.grid。首先,btn1 ...

回答 2 投票 2

具有动态列数的CSS网格容器

我有一个具有这些设置的网格容器-显示:grid; grid-template-columns:1fr 1fr 2fr repeat(4,1fr)2rem; grid-auto-flow:列;网格自动列:1fr;高度:100%;宽度:...

回答 2 投票 0

强制大小调整为img

我的目标是创建一个div元素,该元素的大小在所有情况下都遵循img的大小。我知道图像的尺寸:300 * 200像素。当img宽度为...时模拟img的缩放比例。]]

回答 1 投票 2

为什么我的媒体查询激活时我的网格为什么不工作?

我正在尝试设计一个简单的导航栏。我想将 内容(导航链接)放置在标题内,与徽标(unsplash.it中的随机图像)对齐。我希望此设置为...

回答 1 投票 1

© www.soinside.com 2019 - 2024. All rights reserved.