我有一個線性漸變:2em red, 4em yellow
如何移動背景漸變獨立於容器寬度
.bar {
background: repeating-linear-gradient(90deg, red 0, red 2em, yellow 2em, yellow 6em);
background-position-x: 0em;
}
如果我通過background-position-x: 1em;
我希望我的梯度將開始移動漸變一個1em
向右與1em yellow
塊和2em red
塊。
取而代之,它抓住了紅色的div末尾的前一個塊。所以我得到了3em red, 4em yellow
,這違反了我的規則。
這裏是一個演示: http://codepen.io/anon/pen/XXmOPB?editors=110