引导徽章 HTML
1。引导价值徽章
<span class="badge text-white p-0"><span class="py-1 px-2 rounded" style="background:#5555ff;">value</span></span>
2。引导键值徽章
<span class="badge text-white p-0 m-1"><span class="bg-secondary py-1 px-2 rounded-left">key</span><span class="py-1 px-2 rounded-right" style="background:#007bff;">value</span></span>
在这两种情况下,只需将#5555ff 替换为您的徽章颜色,将value 和key 替换为您的数据。
它们是这样的:
使用 PHP 的动态引导徽章
这个函数只是简单地返回上面的 HTML 并相应地插入颜色、键和值。
function badge($key, $value, $color="5555ff") {
if ($key == "")
return '<span class="badge text-white p-0"><span class="py-1 px-2 rounded" style="background:#' . $color . ';">' . $value . '</span></span>';
return '<span class="badge text-white p-0"><span class="bg-secondary py-1 px-2 rounded-left">' . $key . '</span><span class="py-1 px-2 rounded-right" style="background:#' . $color . ';">' . $value . '</span></span>';
}
然后您可以通过以下方式调用badge() 函数:
// value-badge with the default color (here: #5555ff)
echo badge("", "value");
// value-badge with a custom color (here: yellow)
echo badge("", "value", "ffff00");
// key-value-badge with the default color
echo badge("key", "value");
// key-value-badge with a custom color (here: green)
echo badge("key", "value", "00ff00");
资源