首页 \ 问答 \ 与nth-child的css网格(css grid with nth-child)

与nth-child的css网格(css grid with nth-child)

是否可以使用nth-child创建不均匀列的重复模式? 这就是我所拥有的,但它只适用于第一行:

.three-cols > div:nth-child(1n) {
   width: 50%;
}
.three-cols > div:nth-child(2n) {
  width: 25%; 
}

.three-cols > div:nth-child(3n) {
  width: 25%; 
}

.three-cols > div:nth-child(3n) {
 margin-right: 0;
 }

所以我希望每一行分开:50%,25%,25%

http://codepen.io/garethj/pen/KNpQYd


Is it possible to create a repeating pattern of uneven columns using nth-child? This is what I have, but it only works for the first row:

.three-cols > div:nth-child(1n) {
   width: 50%;
}
.three-cols > div:nth-child(2n) {
  width: 25%; 
}

.three-cols > div:nth-child(3n) {
  width: 25%; 
}

.three-cols > div:nth-child(3n) {
 margin-right: 0;
 }

So I want every row split:50%,25%,25%

http://codepen.io/garethj/pen/KNpQYd


原文:https://stackoverflow.com/questions/40487553
更新时间:2023-07-22 20:07

最满意答案

我编辑了我的答案。 这个例子现在工作正常!


I edited my answer. The example works fine now!

相关问答

更多
  • 您应该能够简化并仅将数据发布为json。 请特别注意type,contentType和data属性。 $.ajax({ cache: false, url: '@Url.Action("InsertPerson", "JsonTest")', type: "POST", contentType: "application/json", data: JSON.stringify(person1), succ ...
  • 我认为Django的csrf漏洞利用保护正在发挥作用。 一个解决方法是通过使用@csrf_exempt装饰get_candidate_prices_and_xpaths来关闭保护(即在此函数之前添加一行,其中只有'@csrf_exempt',并且在django.views.decorators.csrf导入csrf_exempt中的文件中更早) “)。 我的API遇到了类似的问题。 更好的解决方案是将相关片段嵌入页面的模板中。 csrf Django功能是在浏览页面时避免安全漏洞--Django文档解释了更 ...
  • 你需要有一个XMLHttpRequest()的实例来使用open()方法,所以添加下面这行代码: var xmlHttp = new XMLHttpRequest(); 在你使用open()方法之前,像这样: xmlHttp.open("POST", "../JSONServlet", true); 编辑: - 你也有一个错误,正如@james指出的那样,在你做initAjax函数的时候你有一个变量xmlhttp ,因为你的全局变量是xmlHttp ,两者都不一样。 You need to have ...
  • 看起来你没有阻止默认的非ajax表单提交触发。 您的函数可以使用事件参数,您可以使用它来防止默认值。 $(document).ready( function () { $('#searchform').submit( function(event) { event.preventDefault(); //rest of code } ); ...
  • 首先,如果要发送JSON Body,则需要使用POST。 GET只在URL中有变量,这对您不起作用。 同样在Web开发中,一般的共识是您使用POST从用户提交数据。 我已成功使用此功能,测试是使用邮递员完成的: POST: { "username":"00346845869585", "password":"test" } @Controller @EnableAutoConfiguration public class SampleController { @RequestMap ...
  • HTTP请求可以是POST或GET但不是两者都有,并且您的代码试图通过$_POST和$_GET来访问变量,这是不行的。 我建议改用$_REQUEST ,它会照顾它(如果是POST或GET)。 尽管使用了type: "POST" ,但jQuery会将其视为“GET”请求,因为您指向带有查询字符串的URL。 HTTP request can be POST or GET but not both and your code is trying to access variables through $_POST ...
  • 首先, datatype参数指定输出数据的类型,而不是输入的数据。 其次, data参数应该给出一个参数字典,在这种情况下,其中一个参数是已经被字符串化的JSON对象: var jsondata = {"author":"TEST", "title":"XYZ"}; $.ajax({ type : 'POST', dataType : 'json', data: { jsondata : JSON.stringify(jsondata)}, url : '/submitqu ...
  • 我编辑了我的答案。 这个例子现在工作正常! I edited my answer. The example works fine now!
  • 您已正确识别处理Tomcat支持的会话ID的三种方法中的两种。 第三种方法是跟踪会话,但仅限于应用程序通过SSL运行。 在这种情况下,您可以将Tomcat配置为使用SSL会话ID。 如果Servlet调用request.getSession(),则Tomcat始终在响应中包含会话ID。 但是,默认情况下,这些cookie在Tomcat 7以后标记为httpOnly,这意味着它们对javascript不可见(以防止试图窃取cookie的XSS攻击)。 如果会话cookie需要对脚本可见,那么您需要在Web应用 ...
  • 检查servlet映射是否正确写入web.xml 请参考此网址点击此处 Check servlet mapping is correctly written in web.xml please refer this url click here

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)