如何使用偏移而不是线性渐变来定位背景图像

Nil*_*ils 1 css css3

我正在尝试设计一个<select>-Field.
(这是一个仅限IE10的页面,因此互操作性只是我的第二个问题...)

使用:

select
{
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url(images/select-open.png), linear-gradient(#e3dfdb 50%, #d3cec8);
  background-position: right center;
  background-repeat: no-repeat;
  border: solid 1px #adadad;
  border-radius: 3px;
  cursor: pointer;
  outline: none;
  padding-bottom: 3px;
  padding-left: 3px;
  padding-right: 20px;
  padding-top: 3px;
}

select::-ms-expand
{
  display: none;
}
Run Code Online (Sandbox Code Playgroud)

我有类似的东西: Imeg太对了

现在,如果我修改背景位置,background-position: right 10px center;那么我会得到类似的东西白色填充权.

如何在保持线性渐变"一直"的同时,从右边框定位图像10px?顺便说一句:我觉得在我的图像右侧添加10px的透明度不是一种选择;-)

Mr.*_*ien 5

你需要做的是用逗号分隔两个背景的位置.

background-position: FIRST_IMAGE_POSITION, SECOND_IMAGE_POSITION;
Run Code Online (Sandbox Code Playgroud)

所以在你的情况下,图像是第一个,渐变是第二个所以它应该是..

select {
  background-position: right center, 0 0; 
  /* Use pixels instead of right and center for better control... 
     where 1st parameter is x and the other parameter is y
   */

  /* Rest stays the same */
}
Run Code Online (Sandbox Code Playgroud)