[英]Responsive vue style binding on css triangle doesn't work
I added a style binding to my button (a CSS triangle) that should change the border width according to the screen size, but the styles are not applied to the element or somehow not visible.我向我的按钮(一个 CSS 三角形)添加了一个样式绑定,它应该根据屏幕大小更改边框宽度,但 styles 未应用于元素或以某种方式不可见。
(The classes other than .triangle
are from TailwindCSS but they should be self-explanatory) ( .triangle
以外的类来自 TailwindCSS,但它们应该是不言自明的)
The HTML: HTML:
<button
class="triangle absolute bottom-0 z-30"
:style="{
borderLeft: triangle_width + ' solid transparent',
borderRight: triangle_width + ' solid transparent',
borderBottom: triangle_width + ' solid transparent'
}"
@click="action"
@mouseover="toggle"
@mouseleave="toggle"
/>
The CSS: CSS:
.triangle:hover {
border-color: transparent transparent white transparent;
}
.triangle {
transition-property: border-color;
transition-duration: 200ms;
width: 0;
height: 0;
margin-bottom: 3px;
}
The triangle_width
property is working as it should but the style isn't applied. triangle_width
属性正常工作,但未应用样式。 The triangle should only be visible when I hover over it but right now it isn't.只有当我 hover 在它上面时,三角形才应该可见,但现在它不可见。
Thanks for any advice on how to solve this problem.感谢您提供有关如何解决此问题的任何建议。 If more information is needed feel free to ask.如果需要更多信息,请随时询问。
I forgot the px after the triangle_width in the style binding:我忘记了样式绑定中的 triangle_width 之后的 px:
{
borderLeft: this.triangle_width + 'px solid transparent',
borderRight: this.triangle_width + 'px solid transparent',
borderBottom: this.triangle_width + 'px solid transparent'
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.