TailwindCSS 3.0 (二) 设置背景颜色和背景图片的方法 | 您所在的位置:网站首页 › 照片如何调整背景颜色 › TailwindCSS 3.0 (二) 设置背景颜色和背景图片的方法 |
设置背景颜色 background-color
1. 背景颜色 Background Color基础用法透明度自定义主题颜色其他用法
2. 渐变颜色基础用法渐变色标基础用法其他用法
3. 背景图片 Background Image4. 背景大小 Background Size5. 重复背景 Background Repeat基础用法不重复横向重复竖向重复
6. 图片位置 Background Position7. 背景图固定 Background Attachment8. 内容框 Background Origin9. 绘制区域 Background Clip
1. 背景颜色 Background Color
基础用法
格式: bg-{颜色名}-{色号} 示例: bg-gray-100 对应的是 background-color: rgb(243 244 246); 颜色表: https://tailwindcss.com/docs/background-color 透明度格式: bg-{颜色名}-{色号}-{透明度} 示例: bg-sky-500/100 方法一: 在tailwind.config.js文件中的theme.colors或theme.extend.colors定义自定义颜色 // tailwind.config.js module.exports = { theme: { extend: { colors: { 'regal-blue': '#243c5a', }, } } } Button方法二: 使用bg-[{Hex颜色}]的方式 其他用法 Class名属性备注bg-inheritbackground-color: inherit;父级继承background-color属性bg-currentbackground-color: currentColor;背景颜色设置为当前文字颜色bg-transparentbackground-color: transparent;透明背景bg-blackbackground-color: black;黑色背景bg-whitebackground-color: white;白色背景 2. 渐变颜色 基础用法格式: 使用bg-gradient-{方向}格式, 先设置渐变的方向, 然后加上渐变色标. 示例: 格式: 开始颜色from-{color}, 结束颜色to-{color}, 中间颜色via-{color} 示例:
格式: bg-[url('图片路径')] 示例: 4. 背景大小 Background Size ClassDescriptione.g.bg-autobackground-size: auto;![]() ![]() ![]() 格式: bg-repeat 格式: bg-no-repeat 格式: bg-repeat-x 格式: bg-repeat-y
参考链接: [1]: https://www.bilibili.com/video/BV1NK4y1p7RT [2]: https://tailwindcss.com/docs/background-color |
CopyRight 2018-2019 实验室设备网 版权所有 |