You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为chessboard+center_lines多背景设置不同尺寸(仅用background属性)

解决方案

你的代码中第一个渐变后的384px 256px是背景定位值,并非背景尺寸,导致该渐变默认以元素整体尺寸(768×512)显示,不符合64×64的要求。只需给两个渐变分别指定64×64的尺寸,同时保留单个background属性即可实现效果:

<!DOCTYPE html>
<style>
body { margin:0; background-color:#000 }
div { 
  width: 768px;
  height: 512px;
  background: 
    conic-gradient(from 90deg at 1px 1px, #0000 90deg, #5a5 0) 0 0 / 64px 64px,
    repeating-conic-gradient(#a55 0% 25%, #105 25% 50%) 0 0 / 64px 64px;
}
</style>
<div></div>

关键调整说明:

  • 用/ 64px 64px为每个渐变明确设置背景尺寸,确保它们都以64×64的规格重复平铺
  • 将背景定位设为0 0(可省略,默认值即为0 0),让渐变从元素左上角开始排列
  • 两个渐变通过逗号分隔,共同写在单个background属性内,满足你“仅使用单个background属性”的要求

内容的提问来源于stack exchange,提问作者Teamur

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.04 01:35:02