flag-icons README

The project's README from github.com/lipis/flag-icons. As one markdown file: README.md.

flag-icons

A curated collection of all country flags in SVG — plus the CSS for easier integration. See the demo.

Install

You can either download the whole project as is or install it via npm or Yarn:

npm install flag-icons
# or
yarn add flag-icons

Usage

First, you need to import css:

import "/node_modules/flag-icons/css/flag-icons.min.css";

or use CDN:

<link
  rel="stylesheet"
  href="https://cdn.jsdelivr.net/gh/lipis/[email protected]/css/flag-icons.min.css"
/>

or use SASS:

@use "node_modules/flag-icons/sass/flag-icons";

// or with custom configuration
@use "node_modules/flag-icons/sass/flag-icons" with (
  // Override path to flags directory
  $flag-icons-path: "node_modules/flag-icons/flags",

  // Include only specific country flags
  $flag-icons-included-countries: ("gr", "de", "gb")
);

You can find all available variables in sass/_variables.scss.

For using the flags inline with text add the classes .fi and .fi-xx (where xx is the ISO 3166-1-alpha-2 code of a country) to an empty <span>. If you want to have a squared version flag then add the class fis as well. Example:

<span class="fi fi-gr"></span> <span class="fi fi-gr fis"></span>

You could also apply this to any element, but in that case you'll have to use the fib instead of fi and you're set. This will add the correct background with the following CSS properties:

background-size: contain;
background-position: 50%;
background-repeat: no-repeat;

Which means that the flag is just going to appear in the middle of an element, so you will have to set manually the correct size of 4 by 3 ratio or if it's squared add also the flag-icon-squared class.

Development

Run the yarn to install the dependencies after cloning the project and you'll be able to:

To build *.scss files

$ yarn build

To serve it on localhost:8000

$ yarn start

To have only specific countries in the css file, remove the ones that you don't need from the _flag-icons-list.scss file and build it again.

Credits

flag-icons (lipis/flag-icons)

Searching Database…

这是什么?flag-icons 是一套精选的合集,收录了每个国家的国旗 SVG 文件,并附带 CSS/SASS 类,只需一个类名就能把国旗放进网页。
这只是一组图片文件,还是附带现成的 CSS 类?两者都有:既有原始的 SVG 国旗文件,也有编译好的 CSS/SASS 样式表,为每个国家代码定义了一个类,因此你不必自己编写背景图片规则。
我该如何把它添加到项目中?通过 npm 或 Yarn 安装,或直接下载项目文件,然后导入 CSS(或 SASS)并进行链接;也提供 CDN 选项。
使用它需要构建工具吗?不需要,你可以直接链接预构建的 CSS 或使用 CDN;只有当你想从源码自行构建或定制样式表时,才需要 Yarn 和 SASS。
我能只保留自己需要的国家吗?可以,但需要重新构建:从 flag-icons-list.scss 中删除不需要的国家,然后重新编译 SCSS;运行时没有内置的方法可以做到这一点。
我到底该如何在页面上放置国旗?给空元素添加类 .fi 和 .fi-xx(ISO 3166-1-alpha-2 国家代码);如需正方形版本,添加 .fis;如需用作背景国旗,可以对任意类型的元素使用 .fib。
原始国旗图案来自哪里?该项目基于一套较早的、现已删除的 SVG 国旗合集构建,该合集最初由一位名为 koppi 的贡献者创建,README 中有署名。
我能用 Sass 变量代替普通 CSS 来使用国旗吗?可以,项目提供了 sass/variables.scss 文件,其中包含所有可用变量,方便你在自己的 SASS 构建中定制国旗样式。
国旗的尺寸如何正确设置?CSS 会以固定位置设置背景图片,因此你需要手动将元素尺寸设为 4:3 比例(或添加 squared 类以获得 1:1 的国旗)。
What are similar projects?spectre, devicon, pure, tabler, feather, dashboards, Font-Awesome, css.gg
Creator
lipis
Size
16.5 MB
Stars
12.5K
Age
13y
Commits · 90 Days