sablesoft / yii2-flags
yii2应用标志资产
v1.0.0
2020-07-06 14:02 UTC
Requires
- php: >=7.2
- bower-asset/flag-icon-css: *
- yiisoft/yii2: *
This package is auto-updated.
Last update: 2024-09-07 00:02:10 UTC
README
为渲染国家标志的Yii2资产包。
安装
首选的安装方式是通过 composer。
运行以下命令
composer require sablesoft/yii2-flags
或者将以下内容添加到 composer.json 的 require 部分中。
"sablesoft/yii2-flags": "*",
用法
为了将标志与文本内联使用,将类 .flag-icon
和 .flag-icon-xx
(其中 xx
是一个国家的 ISO 3166-1-alpha-2 代码)添加到一个空的 <span>
中。如果您想要一个正方形版本的标志,还可以添加类 flag-icon-squared
。示例
<span class="flag-icon flag-icon-gr"></span> <span class="flag-icon flag-icon-gr flag-icon-squared"></span>
您也可以将其应用于任何元素,但在此情况下,您需要使用 flag-icon-background
而不是 flag-icon
,然后设置即可。这将添加以下CSS属性的正确背景
background-size: contain; background-position: 50%; background-repeat: no-repeat;
这意味着标志将出现在元素的中间,因此您需要手动设置 4:3 比例的正确大小,如果是正方形,还需要添加 flag-icon-squared
类。