此篇延续上一篇元件样式修改,此篇着重在元件的动态效果样式。
撰写动态效果起手式。
$enable-reduced-motion: false !default;
enable-reduced-motion
:禁止动画、过渡设置(预设是 true
)
介绍几个 modal 常调参数
$modal-transition:设置动画时间。
$modal-fade-transform:modal 视窗渐入动画效果。
$modal-show-transform:modal 视窗渐出动画效果。
// 预设效果往下移位
$modal-fade-transform: translate(0, -50px);
// 放大效果
$modal-fade-transform: scale(0.8);
$modal-show-transform vs. $modal-fade-transform
因此查看 $modal-show-transform
、$modal-fade-transform
两者样式,会发觉两者的样式有看似相反的效果。
常用於将元素固定在某个位置。
Step1:设置 top、left、right、bottom 属性
Step2:设置 sticky、fixed 属性
示范将选单固定在最上方
<header class="position-sticky top-0 bg-white">
<nav></nav>
</header>
position-sticky vs. position-fixed
一直固定於画面上。
特性
当 viewport 卷动到超过元素位置後才黏在画面上。
特性
限制
overflow: hidden
,否则会因为无法卷动而失效。建议
position-sticky
,或使用 js 来判断 position-fixed 的触发时机。实现基本的视差滚动效果,bootstrap 原生没有这个属性,需要自行撰写。
透过通用类别撰写 background-attachment 样式。
"background-attachment": (
responsive: true,
property: background-attachment,
class: bga,
values: (
scroll: scroll,
fixed: fixed,
local: local
),
)
编译後的 css
.bga-scroll {
background-attachment: scroll !important;
}
.bga-fixed {
background-attachment: fixed !important;
}
.bga-local {
background-attachment: local !important;
}
撰写 html以及背景图片样式。
.header-banner {
background: url(../images/ricardo-gomez-angel-UrOZTfXT0h0-unsplash.jpg) no-repeat center/cover;
height: 480px;
}
<div class="header-banner bga-fixed"></div>
background-attachment
有支援度的问题。
下方图片左边为 mobile 画面,因为 ios 支援度问题,导致 background-attachment 没有正常缩放,而变成原始大小被裁切过後的图片。
原因
参考文章:How to replicate background-attachment fixed on iOS [duplicate]
解决办法
<div class="header-banner bga-lg-fixed"></div>
Bootstrap 有许多元件都有提供类似下拉选单的功能以及不同的 icon,这边会示范将 icon 更换为 Font Awesome 的方法。
先谈谈为更换 icon 的好处
隐藏 accordion icon 的参数。
$accordion-icon-width: none !default;
$accordion-button-icon: none !default;
$accordion-button-active-icon: none !default;
直接复写 .accordion-button::after
样式,覆盖为 Font Awesome
的 icon 样式。
.accordion-button::after {
font-family: "Font Awesome 5 Free";
font-weight: 900;
content: "\f078";
}
官方文件 CSS Pseudo-elements 伪元素使用方法
Step1:查看 icon style、unicode 代码
Step2:设置样式(font-family
、font-weight
、content
)
font-family: "Font Awesome 5 Free";
font-weight: 900;
content: "\f078";
font-family
、font-weight
参数请参考官方文件中的对应表。
font-family:依照 icon style 来选择对应的 font-family。
font-weight:依照 icon style 来选择对应的 font-weight。
contnet:依照 icon style 来输入对应的 unicode 代码。
font-family 使用多种参数
font-family: "Font Awesome 5 Solid","Font Awesome 5 Free";
font-weight 预设是 400
<<: [Day 29] - React 前端串後端 - 查询订单
manageGaugeVisibility方法 bitmapHeight方法 bitmapWidth...
现在的主流只要会let跟const let宣告变数: 比较严谨的 ex: let cokePrice...
修饰词~可以限制类别的存取层级 我的举例是:像是一些私密的东西你不想让别人随便乱看一样 就要设隐私权...
什麽是模板语法? 模板语法是逻辑与页面之间沟通的媒介,Vue.js 使用了基於HTML 的模板语法,...
前言 加权指数和法人留仓那些都已经完毕了,现在回到个股的讯号灯。这次要做的是MA(移动平均数)的穿越...