Rumah hujung hadapan web tutorial css CSS学习笔记之常用Mixin封装实例代码_CSS教程_CSS_网页制作

CSS学习笔记之常用Mixin封装实例代码_CSS教程_CSS_网页制作

Dec 16, 2017 am 10:06 AM
css mixin

CSS预处理技术现在已经非常成熟,比较流行的有Less,Sass,Stylus,在开发过程中提升我们的工作效率,缩短开发时间,方便管理和维护代码,这篇文章主要给大家分享介绍了关于CSS学习笔记之常用Mixin封装的相关资料,需要学习CSS的朋友们下面随着小编来一起学习学习吧。

前言

为了有效的维护和开发项目,代码的重复利用就显得尤为重要。在Sass中,除了@import和@extend可以使你的代码更加具有重复利用性,@mixin指令也同样能提高你代码的重复使用率并简化你的代码。个人在做项目的过程中总结归纳的一些常用Mixin,现在分享出来供大家学习。

基于Less编写。但是CSS预处理器都是相通的,你可以很轻易的修改成Sass、Stylus

代码免不了错误和Bug,如果你能帮我修改或者补充 万分感谢!!

参考了一些开源库,如:est、csslab等

Usage


/**
* 作品:mixin.less
* 更新:2017年12月14日
* 简介:1. 一个基于 Less 的样式工具库,封装了常用 mixin,帮助您更轻松地书写 Less 代码。
*       2. 只在调用时才输出代码,减少代码冗余,避免样式污染
*       3. 不自带兼容前缀,减少代码量,而建议采用工具生成,如 postcss、Autoprefixer、less-plugin-autoprefix 等
*       4. 附带 IE 各类 Hack
*/
/*-------------------------------------
├   布局                              ┆
└------------------------------------*/
// 盒子宽高
.size(@w, @h) { width: @w; height: @h; }
// 最小尺寸, 兼容IE6
.min-width(@min-w) { min-width: @min-w; _width: @min-w; }
.min-height(@min-h) { min-height: @min-h; _height: @min-h; }
// 内联块级元素, 兼容IE6
.dib() { display: inline-block; *display: inline; *zoom: 1; }
// 固定定位, 兼容IE6
.fixed() { position: fixed; _position: absolute; *zoom: 1; }
// 统一盒模型
.border-box() {
  *, *:after, *:before { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; }
}
// 文字图片居中
.center(text-x) { text-align: center; }
.center(text-y) { display: table-cell; vertical-align: middle; }
// 块级元素水平居中
.center(auto-x) { display: block; margin-left: auto; margin-right: auto; }
// 居中, 不确定尺寸, 不兼容 IE6
.center(unknown) { position: absolute; top: 0; left: 0; right: 0; bottom: 0; margin: auto; }
.center(unknown-x) { position: absolute; left: 0; right: 0; margin-left: auto; margin-right: auto; }
.center(unknown-y) { position: absolute; top: 0; bottom: 0; margin-top: auto; margin-bottom: auto; }
// 居中, 确定尺寸, 兼容 IE6
.center(known, @w, @h) {
  .size(@w, @h);
  position: absolute; top: 50%; left: 50%; margin-top: -(@w / 2); margin-left: -(@h / 2);
}
.center(known-x, @w) {
  width: @w;
  position: absolute; left: 50%; margin-left: -(@h / 2);
}
.center(known-y, @h) {
  height: @h;
  position: absolute; top: 50%; margin-top: -(@w / 2);
}
// 居中, CSS3 平移方式, 兼容性不行
.center(translate) { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }
// 居中, Flex 方式, 兼容性不行
.center(flex) { display: flex; align-items: center; justify-content: center; }
// 多个子项布局
.list(float, @w: 25%) { float: left; width: @w; }
.list(inline, @w: 25%) { .dib(); width: @w; }
.list(flex) { flex: 1; }
// 遮罩层, 全屏遮罩、区域遮罩
.over-screen(fixed) { .fixed(); top: 0; left: 0; right: 0; bottom: 0; }
.over-screen(absolute) { position: absolute; top: 0; left: 0; right: 0; bottom: 0; }
// 容器宽高比固定
// 100* 1/1 = 100%
// 100* 3/4 = 75%
.fixed-ratio(@padding-top: 100%) {
  position: relative; width: 100%; height: 0; padding-top: @padding-top;
  img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
}
// 扩展点击区域
.extend-click() {
  position: relative;
  &:before { content: ''; position: absolute; top: -10px; left: -10px; right: -10px; bottom: -10px; }
}
// 定宽居中页面布局
.layout-page(@width: 1200px) { width: @width; margin-left: auto; margin-right: auto; }
// 侧边栏
// 主要区域:overflow: hidden; margin-left: xx; margin-right: xx;
.sidebar(left, @width) { position: absolute; top: 0; left: 0; width: @width; }
.sidebar(right, @width) { position: absolute; top: 0; right: 0; width: @width; }
/*-------------------------------------
├   字体                              ┆
└------------------------------------*/
// 字体大小
.fz(@fz) { font-size: @fz; }
// 字体大小与行高
.fz(@fz, @lh) { font-size: @fz; line-height: @lh; }
// 字体大小、行高、高度
.fz(@fz, @h, @lh: @h) { font-size: @fz; height: @h; line-height: @lh; }
// 行高与高度
.lh(@h, @lh: @h) { height: @h; line-height: @lh; }
// 字体颜色, 包括链接与非链接
.color(@color) { color: @color;}
// 字体颜色 + 自身 Hover
.color(@color, @hovercolor) {
  color: @color;
  &:hover { color: @hovercolor; }
}
// 字体颜色 + 链接 Hover
.color(@color, @acolor, @hovercolor) {
  color: @color;
  a {
    color: @acolor;
    &:hover { color: @hovercolor; }
  }
}
// 正常字体样式
.normal-font() { font-weight: normal; font-style: normal; }
// 辅助性文字(灰色)
.assist-font(@color: #b0b0b0, @fz: 14px) { color: @color; font-size: @fz; }
// 禁止换行, 文本溢出省略号显示 (一行)
.ellipsis() {
  white-space: normal; word-wrap: break-word; word-break: break-all;
  -o-text-overflow: ellipsis; -ms-text-overflow: ellipsis; text-overflow:ellipsis; overflow:hidden;
}
// 文本溢出省略号显示 (多行)
// 只支持 webkit 浏览器, 解决方案:高度 = 行高*行数
// height: 90px; line-height: 30px; -webkit-line-clamp: 3;
.ellipsis-mult(@n: 3) {
  display: -webkit-box; -webkit-box-orient: vertical;-webkit-line-clamp: @n; word-break: break-all;
  -o-text-overflow: ellipsis; -ms-text-overflow: ellipsis; text-overflow:ellipsis; overflow: hidden;
}
// 书写模式:牌匾从右至左水平单行排版效果、文笺从右至左、从上至下排版效果
.retext(x) { direction: rtl; unicode-bidi: bidi-override; }
.retext(y) { writing-mode: tb-rl; writing-mode: vertical-rl; }
// 文字透明
.transparent-text() { font: 0/0 serif; text-shadow: none; color: transparent; }
// 文字隐藏(常用于SEO优化)
// <a href="" title="Logo SEO 优化 "><h1 class="logo">xx</h1></a>
.hidden-text() { text-indent : -9999px; overflow: hidden; text-align: left; }
// 文字外发光效果
.glow-text(@r: 10px, @color: gold) { text-shadow: 0 0 @r @color; }
/*-------------------------------------
├   图像                              ┆
└------------------------------------*/
// 用 max-width 来防止图片撑破容器
.max-img() { display: block; max-width: 100%; height: auto; }
// 2x 3x 背景图片
.bg-image(@url) {
  background-image: url("@url + &#39;@2x.png&#39;");
  @media (-webkit-min-device-pixel-ratio: 3), (min-device-pixel-ratio: 3) {
    background-image: url("@url + &#39;@3x.png&#39;");
  }
}
// 全屏大图背景
.fullscreen-bg(@url) {
  width: 100vw;
  height: 100vh;
  background: url(@url) no-repeat 50% 50%;
  background-size: cover;
}
// 滤镜: 将彩色照片显示为黑白照片
.grayscale() {
  filter: grayscale(100%);
  -webkit-filter: grayscale(100%);
  -moz-filter: grayscale(100%);
  -ms-filter: grayscale(100%);
  -o-filter: grayscale(100%);
}
/*-------------------------------------
├   动效                              ┆
└------------------------------------*/
// 链接默认无下划线,hover后有下划线的样式
.hover-link() {
  text-decoration: none;
  &:hover { text-decoration: underline; }
}
// 将链接变成默认的文字样式
.unstyled-link() {
  color: inherit;
  cursor: inherit;
  text-decoration: inherit;
  &:active, &:focus { outline: none; }
}
// 盒子阴影
// box-shadow: 水平阴影的位置, 垂直阴影的位置, 模糊距离, 阴影的大小, 阴影的颜色, 阴影开始方向(默认是从里往外,设置inset就是从外往里);
// box-shadow: h-shadow v-shadow blur spread color inset;
.box-shadow() {
  box-shadow: 0px 14px 26px 0px rgba(0, 0, 0, 0.1);
}
// 盒子 Hover
.box-hover() {
  // box-shadow: 0px 1px 2px 0px rgba(84, 107, 107, .4);
  transition: all .2s linear;
  &:hover {
    box-shadow: 0 15px 30px rgba(0, 0, 0, .1);
    transform: translate3d(0, -2px, 0);
  }
}
.box-hover2() {
  transition: transform .5s ease;
  &:hover {
    transform: translateX(10px);
  }
}
// 三维闪动 bug 处理
.transform-fix() { -webkit-backface-visibility: hidden; -webkit-transform-style: preserve-3d; }
// Animation
.ani(@name, @time: 1s, @ease: ease-in-out, @fillmode: forwards) {
  animation-name: @name;
  animation-duration: @time;
  animation-timing-function: @ease;
  animation-fill-mode: @fillmode;
}
/*-------------------------------------
├   功能                              ┆
└------------------------------------*/
// 浮动, 兼容 IE6
.fl() { float: left; *display: inline; _display:inline; }
.fr() { float: right; *display: inline; _display:inline; }
// 清除浮动
.clearfix() {
  *zoom: 1;
  &:after { display: block; clear: both; content: &#39;&#39;; visibility: hidden; height: 0; }
}
.clearfix(table) {
  *zoom: 1;
  &:before, &:after { content: " "; display: table; clear: both; }
}
// 禁止文本被选择
.user-select() { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; }
// 隐藏鼠标手势
.hide-cursor() { cursor: none !important; }
// 鼠标禁用样式,但仍然可以触发事件
// <input type="text" disabled="disabled">
.disabled() { cursor: not-allowed; }
// 禁用元素事件
// 1. 阻止任何点击动作的执行
// 2. 使链接显示为默认光标(cursor:default)
// 3. 阻止触发hover和active状态
// 4. 阻止JavaScript点击事件的触发
.pointer-events() { pointer-events: none; }
// 模糊
.blur(@blur: 10px) {
  filter: blur(@blur);
  -webkit-filter: blur(@blur);
  -moz-filter: blur(@blur);
  -o-filter: blur(@blur);
  -ms-filter: blur(@blur);
  filter: progid:DXImageTransform.Microsoft.Blur(PixelRadius=&#39;@{blur}&#39;);
  *zoom: 1;
}
// 透明度, 兼容 IE8
.opacity(@opacity: 20) { opacity: @opacity / 100; filter: alpha(opacity=@opacity); }
// 用伪类来显示打印时 a 标签的链接
.print-link() {
  @media print {
    a[href]:after { content: " (" attr(href) ") "; }
  }
}
// 隔行换色
.zebra-lists(odd, @color) {
  &.odd {
    >li:nth-child(odd) { background-color: @color; }
  }
}
.zebra-lists(even, @color) {
  &.even {
    >li:nth-child(even) { background: green; }
  }
}
// 首字下沉
.first-letter(@font-size: 6em) {
  &::first-letter{
    float: left;
    line-height: 1;
    font-size: @font-size;
  }
}
// 特殊标记段落第一行
.first-line() {
  &::first-line{
    color: red
  }
}
// 美化选中文本
.beauty-select() {
  &::selection{
   color: #fff;
   background-color: #6bc30d;
   text-shadow: none;
  }
}
// 美化占位符 placeholder 样式
.beauty-placeholder(@fz, @color: #999, @align: left) {
  &:-moz-placeholder { font-size: @fz; color: @color; text-align: @align; }
  &:-ms-input-placeholder { font-size: @fz; color: @color; text-align: @align; }
  &::-webkit-input-placeholder { font-size: @fz; color: @color; text-align: @align; }
}
// 美化占位符 placeholder 样式(自定义属性和值)
.beauty-placeholder(custom, @property, @value) {
  &:-moz-placeholder { @{property}: @value; }
  &:-ms-input-placeholder { @{property}: @value; }
  &::-webkit-input-placeholder { @{property}: @value; }
}
/*-------------------------------------
├   图形                              ┆
└------------------------------------*/
// 三角形
.triangle(@width: 4px,@color: #000) {
  display: inline-block;
  width: 0;
  height: 0;
  vertical-align: middle;
  border-top: @width solid @color;
  border-left: @width solid transparent;
  border-right: @width solid transparent;
}
// 三角形箭头气泡效果, IE6-7 无表现
.arrow(top, @w: 10px, @color, @x: 50%) {
  position: relative;
  &:before { position: absolute; bottom: 100%; left: @x; content: " "; height: 0; width: 0; pointer-events: none; border-style: solid; border-color: transparent; border-bottom-color: @color; border-width: unit(@w, px); @margin: -@w; margin-left: unit(@margin, px); }
}
.arrow(right, @w: 10px, @color, @y: 50%) {
  position: relative;
  &:before { position: absolute; left: 100%; top: @y; content: " "; height: 0; width: 0; pointer-events: none; border-style: solid; border-color: transparent; border-left-color: @color; border-width: unit(@w, px); @margin: -@w; margin-top: unit(@margin, px); }
}
.arrow(bottom, @w: 10px, @color, @x: 50%) {
  position: relative;
  &:before { position: absolute; top: 100%; left: @x; content: " "; height: 0; width: 0; pointer-events: none; border-style: solid; border-color: transparent; border-top-color: @color; border-width: unit(@w, px); @margin: -@w; margin-left: unit(@margin, px); }
}
.arrow(left, @w: 10px, @color, @y: 50%) {
  position: relative;
  &:before { position: absolute; right: 100%; top: @y; content: " "; height: 0; width: 0; pointer-events: none; border-style: solid; border-color: transparent; border-right-color: @color; border-width: unit(@w, px); @margin: -@w; margin-top: unit(@margin, px); }
}
// 三角形箭头气泡效果, 带边框
.arrow-with-border(top, @w: 10px, @color, @border-w: 1px, @border-color, @x: 50%) {
  position: relative;
  &:before, &:after { bottom: 100%; left: @x; content: " "; height: 0; width: 0; position: absolute; pointer-events: none; border-style: solid; border-color: transparent; }
  &:after { border-bottom-color: @color; border-width: unit(@w, px); @margin: -@w; margin-left: unit(@margin, px); }
  &:before { border-bottom-color: @border-color; @arrbo: @w+@border-w; border-width: unit(@arrbo, px); @margin-bo: -@arrbo; margin-left: unit(@margin-bo, px); }
}
.arrow-with-border(bottom, @w: 10px, @color, @border-w: 1px, @border-color, @x: 50%) {
  position: relative;
  &:before, &:after { top: 100%; left: @x; content: " "; height: 0; width: 0; position: absolute; pointer-events: none; border-style: solid; border-color: transparent; }
  &:after { border-top-color: @color; border-width: unit(@w, px); @margin: -@w; margin-left: unit(@margin, px); }
  &:before { border-top-color: @border-color; @arrbo: @w+@border-w; border-width: unit(@arrbo, px); @margin-bo: -@arrbo; margin-left: unit(@margin-bo, px); }
}
.arrow-with-border(left, @w: 10px, @color, @border-w: 1px, @border-color, @y: 50%) {
  position: relative;
  &:before, &:after { top: @y; right: 100%; content: " "; height: 0; width: 0; position: absolute; pointer-events: none; border-style: solid; border-color: transparent; }
  &:after { border-right-color: @color; border-width: unit(@w, px); @margin: -@w; margin-top: unit(@margin, px); }
  &:before { border-right-color: @border-color; @arrbo: @w+@border-w; border-width: unit(@arrbo, px); @margin-bo: -@arrbo; margin-top: unit(@margin-bo, px); }
}
.arrow-with-border(right, @w: 10px, @color, @border-w: 1px, @border-color, @y: 50%) {
  position: relative;
  &:before, &:after { top: @y; left: 100%; content: " "; height: 0; width: 0; position: absolute; pointer-events: none; border-style: solid; border-color: transparent; }
  &:after { border-left-color: @color; border-width: unit(@w, px); @margin: -@w; margin-top: unit(@margin, px); }
  &:before { border-left-color: @border-color; @arrbo: @w+@border-w; border-width: unit(@arrbo, px); @margin-bo: -@arrbo; margin-top: unit(@margin-bo, px); }
}
/*-------------------------------------
├   组件                              ┆
└------------------------------------*/
// 吸顶导航
.fix-header(@h: 70px) {
  .fixed();
  top: 0;
  left: 0;
  width: 100%;
  height: @h;
  z-index: 1000;
  // background-color: rgba(256, 256, 256, .92);
  // border-bottom: 1px solid rgba(7, 17, 27, 0.1);
  // box-shadow: 0px 0px 20px rgba(0,0,0,0.2);
}
// 吸底导航
.fix-header(@h: 70px) {
  .fixed();
  left: 0;
  bottom: 0;
  width: 100%;
  height: @h;
  z-index: 1000;
}
// 输入框
.input-text() {
  display: block;
  width: 100%;
  padding: 4px 8px;
  font-size: 14px;
  line-height: 1.42858;
  color: #333;
  border: 1px solid #ddd;
  background-color: #fff;
  border-radius: 3px;
}
// 分割线
// <span class="separator">|/-</span>
.separator() {
  margin: 0 10px;
  color: #999;
  font-size: 14px;
}
// 分割线 / (面包屑导航)
.separator2() {
  &:before {
    padding: 0 5px;
    color: #ccc;
    content: "/\00a0";
  }
}
// <hr class="hr">
// 支付宝:我也是有底线的
.hr() {
  height: 1px;
  margin: 10px 0;
  border: 0;
  clear: both;
  background-color: #e2e2e2;
}
// 改装的 fieldset
// <fieldset><legend>返璞归真</legend></fieldset>
.fieldset() {
  border-color: #d2d2d2;
  border-width: 1px 0 0;
  border-style: solid;
  legend {
    padding: 0 20px;
    text-align: center;
    font-size: 20px;
    font-weight: 300;
  }
}
// 引用区块(模仿 Layui)
// <p class="blockquote">Lorem ipsum dolor sit amet.</p>
.blockquote() {
  margin-bottom: 10px;
  padding: 15px;
  line-height: 22px;
  border-left: 5px solid #009688;
  border-radius: 0 2px 2px 0;
  background-color: #f2f2f2;
}
// 徽章 (椭圆、小圆点)
// <span class="badge">10</span>
.badge(...) {
  position: relative;
  display: inline-block;
  font-size: 12px;
  color: #fff;
  background-color: #FF5722;
}
.badge(ellipse) {
  min-width: 8px;
  height: 18px;
  padding: 2px 6px;
  text-align: center;
  line-height: 18px;
  border-radius: 9px;
}
.badge(dot) {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
// 关闭按钮
// <button class="close" type="button"><span>&times;</span></button>
.close() {
  position: relative;
  -webkit-appearance: none;
  padding: 0;
  cursor: pointer;
  background: 0 0;
  border: 0;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  color: #000;
  text-shadow: 0 1px 0 #fff;
  filter: alpha(opacity=20);
  opacity: .2;
  &:hover {
    color: #000;
    text-decoration: none;
    cursor: pointer;
    filter: alpha(opacity=50);
    opacity: .5;
  }
  &:before {
    content: &#39;&#39;;
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
  }
}
// 1 像素边框问题
.onepx(...) {
  position: relative;
  &:after {
    content: &#39;&#39;;
    display: block;
    position: absolute;
    left: 0;
    width: 100%;
    border-top: 1px solid rgba(7, 17, 27, 0.1);
    transform: scaleY(0.5);
  }
}
.onepx(top) { &:after { top: 0; } }
.onepx(bottom) { &:after { bottom: 0; } }
.onepx-easy(top, @color: #ccc) { box-shadow: inset 0px -1px 1px -1px @color; }
.onepx-easy(bottom, @color: #ccc) { box-shadow: inset 0px 1px 1px -1px @color; }
Salin selepas log masuk


总结

以上就是本文的所有内容,希望会给大家带来帮助!!

相关推荐:

用纯CSS制作带动画的天气图标方法教程

CSS实现相册横向完美排布方法

CSS3中使用视窗单位来布局的方法

Atas ialah kandungan terperinci CSS学习笔记之常用Mixin封装实例代码_CSS教程_CSS_网页制作. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!

Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn

Alat AI Hot

Undresser.AI Undress

Undresser.AI Undress

Apl berkuasa AI untuk mencipta foto bogel yang realistik

AI Clothes Remover

AI Clothes Remover

Alat AI dalam talian untuk mengeluarkan pakaian daripada foto.

Undress AI Tool

Undress AI Tool

Gambar buka pakaian secara percuma

Clothoff.io

Clothoff.io

Penyingkiran pakaian AI

AI Hentai Generator

AI Hentai Generator

Menjana ai hentai secara percuma.

Artikel Panas

R.E.P.O. Kristal tenaga dijelaskan dan apa yang mereka lakukan (kristal kuning)
3 minggu yang lalu By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Tetapan grafik terbaik
3 minggu yang lalu By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Cara Memperbaiki Audio Jika anda tidak dapat mendengar sesiapa
3 minggu yang lalu By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: Cara Membuka Segala -galanya Di Myrise
4 minggu yang lalu By 尊渡假赌尊渡假赌尊渡假赌

Alat panas

Notepad++7.3.1

Notepad++7.3.1

Editor kod yang mudah digunakan dan percuma

SublimeText3 versi Cina

SublimeText3 versi Cina

Versi Cina, sangat mudah digunakan

Hantar Studio 13.0.1

Hantar Studio 13.0.1

Persekitaran pembangunan bersepadu PHP yang berkuasa

Dreamweaver CS6

Dreamweaver CS6

Alat pembangunan web visual

SublimeText3 versi Mac

SublimeText3 versi Mac

Perisian penyuntingan kod peringkat Tuhan (SublimeText3)

Cara menggunakan butang bootstrap Cara menggunakan butang bootstrap Apr 07, 2025 pm 03:09 PM

Bagaimana cara menggunakan butang bootstrap? Perkenalkan CSS bootstrap untuk membuat elemen butang dan tambahkan kelas butang bootstrap untuk menambah teks butang

Cara mengubah saiz bootstrap Cara mengubah saiz bootstrap Apr 07, 2025 pm 03:18 PM

Untuk menyesuaikan saiz unsur-unsur dalam bootstrap, anda boleh menggunakan kelas dimensi, yang termasuk: menyesuaikan lebar: .col-, .w-, .mw-adjust ketinggian: .h-, .min-h-, .max-h-

Cara melihat tarikh bootstrap Cara melihat tarikh bootstrap Apr 07, 2025 pm 03:03 PM

Jawapan: Anda boleh menggunakan komponen pemetik tarikh bootstrap untuk melihat tarikh di halaman. Langkah -langkah: Memperkenalkan rangka kerja bootstrap. Buat kotak input pemilih Tarikh dalam HTML. Bootstrap secara automatik akan menambah gaya kepada pemilih. Gunakan JavaScript untuk mendapatkan tarikh yang dipilih.

Cara Menulis Garis Pecah Di Bootstrap Cara Menulis Garis Pecah Di Bootstrap Apr 07, 2025 pm 03:12 PM

Terdapat dua cara untuk membuat garis perpecahan bootstrap: menggunakan tag, yang mewujudkan garis perpecahan mendatar. Gunakan harta sempadan CSS untuk membuat garis perpecahan gaya tersuai.

Cara memasukkan gambar di bootstrap Cara memasukkan gambar di bootstrap Apr 07, 2025 pm 03:30 PM

Terdapat beberapa cara untuk memasukkan imej dalam bootstrap: masukkan imej secara langsung, menggunakan tag HTML IMG. Dengan komponen imej bootstrap, anda boleh memberikan imej yang responsif dan lebih banyak gaya. Tetapkan saiz imej, gunakan kelas IMG-cecair untuk membuat imej boleh disesuaikan. Tetapkan sempadan, menggunakan kelas IMG-Sempadan. Tetapkan sudut bulat dan gunakan kelas IMG-bulat. Tetapkan bayangan, gunakan kelas bayangan. Saiz semula dan letakkan imej, menggunakan gaya CSS. Menggunakan imej latar belakang, gunakan harta CSS imej latar belakang.

Cara Menyiapkan Kerangka untuk Bootstrap Cara Menyiapkan Kerangka untuk Bootstrap Apr 07, 2025 pm 03:27 PM

Untuk menubuhkan rangka kerja bootstrap, anda perlu mengikuti langkah -langkah ini: 1. Rujuk fail bootstrap melalui CDN; 2. Muat turun dan tuan rumah fail pada pelayan anda sendiri; 3. Sertakan fail bootstrap di HTML; 4. Menyusun sass/kurang seperti yang diperlukan; 5. Import fail tersuai (pilihan). Setelah persediaan selesai, anda boleh menggunakan sistem grid Bootstrap, komponen, dan gaya untuk membuat laman web dan aplikasi yang responsif.

Cara Mengesahkan Tarikh Bootstrap Cara Mengesahkan Tarikh Bootstrap Apr 07, 2025 pm 03:06 PM

Untuk mengesahkan tarikh dalam bootstrap, ikuti langkah -langkah ini: memperkenalkan skrip dan gaya yang diperlukan; memulakan komponen pemilih tarikh; Tetapkan atribut data-BV-tarikh untuk membolehkan pengesahan; Konfigurasikan peraturan pengesahan (seperti format tarikh, mesej ralat, dll.); Mengintegrasikan rangka kerja pengesahan bootstrap dan mengesahkan input tarikh secara automatik apabila borang dikemukakan.

Cara menggunakan bootstrap di vue Cara menggunakan bootstrap di vue Apr 07, 2025 pm 11:33 PM

Menggunakan bootstrap dalam vue.js dibahagikan kepada lima langkah: Pasang bootstrap. Import bootstrap di main.js. Gunakan komponen bootstrap secara langsung dalam templat. Pilihan: Gaya tersuai. Pilihan: Gunakan pemalam.

See all articles