【发布时间】:2021-02-08 11:58:13
【问题描述】:
我正在尝试使用 JSX 和内联 CSS 为尺寸增加的元素制作动画
const iconHtml = `<div style="background: url('${iconUrl}'); width: 100%; height: 100%; transition: 0.5s; background-repeat: round; transform: scale(4);"onmouseover="this.style.scale=2;"onmouseout="this.style.scale=1;"" >
<p style="margin-bottom: 0;position: relative;left: 70px;width: max-content;top: 20px;font-size: 16px; font-weight: 600;>
${steps?.length < 10 ? item.title : ""}
</p>
</div>`;
const icon = L.divIcon({
html: !hovered ? iconHtml : iconHtml,
});
目前,我正在尝试在 HTML: !hovered ? iconHtml :iconHtml 的占位符处添加一个新的 if 语句,并尝试了不同的方法,例如 iconHtml.style.scale 但是它仍然给我错误。有没有办法使用 javascript 在内联 CSS 之外的 if 语句中更改项目的大小?如果不是,有没有办法将 if 语句放入内联中,表示 if !hovered 然后它会改变大小?
提前谢谢你
【问题讨论】:
-
这看起来不像 JSX?
-
完整程序使用JSX,但这里没有实现,有没有办法只使用javascript?或者 JSX 中我可以利用的任何东西?
标签: javascript css jsx transform