【发布时间】:2017-01-05 16:40:49
【问题描述】:
我尝试插入以下代码来替换我在线商店上添加到购物车按钮的 CSS 样式,因此当产品为 0 时需要显示“订单”而不是产品大于 1 需要显示“添加到购物车”,但是 .hideen 类(大于 >= )不起作用,而另一个是的..
{if $product->quantity <= 0}
<style type="text/css">
{literal}
.hideeen {display:none;}
{/literal}
</style>
{/if}
{if $product->quantity >= 1}
<style type="text/css">
{literal}
.hideen {display:none;}
{/literal}
</style>
{/if}
您可以看到将应用 HTML 的位置:
<button type="submit" name="Submit" class="exclusive">
<span class="btn">
{if $content_only && (isset($product->customization_required) && $product->customization_required)}<em>{l s='Customize'}</em>{else}<em class="hideeen">{l s='Add to cart'}</em>{/if}<em class"hideen">{l s='order'}</em>
</span>
</button>
【问题讨论】:
-
你真的用一个字符来区分这两个类吗(
hideenvshideeen)?这非常很容易被误读,而且我花费的时间比理解你的问题所花费的时间要长得多。考虑使用更易读的东西。 -
为什么首先要为此设置两个不同的样式类?为什么不是 SINGLE 样式,而是使用类似
<style>.hide { display: {smartycodehere} }</style>的东西来生成只是一个无/块类型的东西? -
你在两个 if 条件下都使用相同的 css..那么为什么不只使用一个类??
-
可读性是相对的,对 Sasha 可读的内容对你可能不可读;不会出错。
-
@MarcB 你是什么意思?我不明白你应该在 {smartycodehere} 上插入什么代码,你能更清楚地发布吗?我想显示一个并隐藏另一个(例如 CSS 上带有 @ 媒体的断点)。但我的第一个问题是,为什么“大于 >=”代码不起作用?当我尝试插入它时页面崩溃..
标签: php css smarty prestashop prestashop-1.6