Rect x和y属性在Firefox中不起作用

伦敦804

我正在使用svgs,并且有两个“ rect”元素。它们具有宽度,高度,x和y的四个css属性。它可以在Chrome和Safari上正常运行,但是在Firefox上,x和y属性不会显示。当我在检查器中手动添加它们时,在x和y属性旁边有一个带有感叹号的三角形,这意味着它无效。我对此感到惊讶,因为当我访问Mozilla开发人员网站时,可以看到它们是有效的属性。由于根据Firefox浏览器,x和y无效,这导致我的SVG无法呈现。我不确定自己在做什么错。解决方法是什么?

<button
   class="button button--plusButton"
   data-ng-click="plus.toggleState()"
   data-ng-class="{'is-checked':plus.state}">
   <svg viewBox="-7 9 24 24" xml:space="preserve">
      <rect class="plusButton-topBar"/>
      <rect class="plusButton-bottomBar"/>
   </svg>
</button>

.plusButton-topBar {
   x: 4px;
   y: 16.5px;
   width: 2px;
   height: 9px;
}

.plusButton-bottomBar {
   x: 0.5px;
   y: 20px;
   width: 9px;
   height: 2px;
}

.plusButton-topBar, .plusButton-bottomBar {
   fill: #656c75;
   -webkit-transform: matrix(1, 0, 0, 1, 0, 0);
   transform: matrix(1, 0, 0, 1, 0, 0);
   transition: all 0.218s ease;
}
什么

您在这里有2期。

  1. X和Y无效的CSS属性。
    • 将它们移动到内联属性。
  2. 您的SVG元素需要尺寸。
    • 添加高度和宽度。

button svg { /*add dimensions*/
  height: 20px; 
  width: 20px;
}
.plusButton-topBar {
 /*x: 4px;
   y: 16.5px;  Move these */
   width: 2px;
   height: 9px;
}

.plusButton-bottomBar {
 /*x: 0.5px;
   y: 20px;  and these*/
   width: 9px;
   height: 2px;
}

.plusButton-topBar, .plusButton-bottomBar {
   fill: #656c75;
   -webkit-transform: matrix(1, 0, 0, 1, 0, 0);
   transform: matrix(1, 0, 0, 1, 0, 0);
   transition: all 0.218s ease;
}
<button class="button button--plusButton" data-ng-click="plus.toggleState()" data-ng-class="{'is-checked':plus.state}">
  <svg viewBox="-7 9 24 24" xml:space="preserve">
    <rect x="4" y="16.5" width="2" height="9" class="plusButton-topBar" />
    <rect x="0.5" y="20" width="9" height="2" class="plusButton-bottomBar" />
  </svg>
</button>


只是一个想法...

您可以使用文本而不是svg。

button{
  color:#656c75;
  font: 1.5em "arial";
  }
<button
   class="button button--plusButton"
   data-ng-click="plus.toggleState()"
   data-ng-class="{'is-checked':plus.state}">
 +
</button>

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

为什么play_button.rect.collidepoint(mouse_x,mouse_y)不起作用?

来自分类Dev

Android Rect相交不起作用

来自分类Dev

剪辑中的javascript引用变量:rect不起作用

来自分类Dev

KineticJS单击Rect的右侧在Chrome中不起作用

来自分类Dev

剪辑中的javascript引用变量:rect不起作用

来自分类Dev

从许多rect中查找最接近的rect

来自分类Dev

为什么rect在Firefox中需要width和height属性?

来自分类Dev

知道DPI和Rect

来自分类Dev

rect.collisionrect在两个rect之间不起作用

来自分类Dev

self.rect = pygame.Rect(x,y,width,height)TypeError:参数必须是rect样式对象

来自分类Dev

pygame碰撞不起作用-pygame.sprite.collide_rect()

来自分类Dev

图形将 rect 溢出填充到新的 rect 中?

来自分类Dev

了解OpenCV C ++中的Rect

来自分类Dev

计算文件中的rect数

来自分类Dev

检测精灵是否在Rect中?

来自分类Dev

"->" 在 "rect(Surface, color, Rect, width=0) -> Rect" 中是什么意思

来自分类Dev

Python类中缺少'rect'属性?

来自分类Dev

pygame对象没有属性'rect'(pygame)

来自分类Dev

AttributeError:对象没有属性rect

来自分类Dev

AttributeError:'class'对象没有属性'rect'

来自分类Dev

使用ggplot和geom_rect

来自分类Dev

我正在尝试在svg元素中创建一个rect元素,但是它不起作用

来自分类Dev

仅当 rect 已被“击中”x 次时,如何使用“colliderect”删除 pygame 中的 rect

来自分类Dev

iOS 7中的Round Rect UIBarButton

来自分类Dev

在Rect中居中和自动调整文本

来自分类Dev

在Pygame Rect中写数字/文字

来自分类Dev

从向量中擦除opencv rect对象

来自分类Dev

PyQT:在rect中绘制QPainterPath()吗?

来自分类Dev

我想用sdl中的图片替换rect

Related 相关文章

热门标签

归档