我想用白色回显success_flash,但是我不能用$ product ['title']做到。
在下面的行中,我想用白色回显所有内容,但此行不起作用:
$_SESSION['success_flash'] = $product['title'].'<span style="color:white;text-align:center;"> has been added to your cart!</span>';
我也尝试过
$_SESSION['success_flash'] = '<span style="color:white;text-align:center;"> $product['title']</span>'. '<span style="color:white;text-align:center;"> has been added to your cart!</span>';
但这对我也不起作用。
答案 0 :(得分:0)
您可以添加!important来强制覆盖先前的color
值,尽管这可能不是最佳做法:
$_SESSION['success_flash'] = '
<span style="color:white!important;text-align:center;">
'.$product['title'].'
</span>
<span style="color:white!important;text-align:center;">
has been added to your cart!
</span>
';
答案 1 :(得分:0)
尝试
$_SESSION['success_flash'] = '<span style="color:white;text-align:center;">'. $product['title']. ' has been added to your cart!</span>';
或
$_SESSION['success_flash'] = '<span style="color:#FFFFFF;text-align:center;">'. $product['title']. ' has been added to your cart!</span>';
您可以添加背景色以检查是否可用,然后可以删除背景色
喜欢
$_SESSION['success_flash'] = '<span style="background-color:#FF0000; padding:5px; color:#FFFFFF;text-align:center;">'. $product['title'] . ' has been added to your cart!</span>';
或尝试使用如下的CSS类
<style>
.myspan {
color: white;
text-align:center;
}
</style>
$_SESSION['success_flash'] = '<span class="myspan">'. $product['title']. ' has been added to your cart!</span>';