Bootstrap图片替换

2023-11-27 78

Bootstrap是一个流行的前端框架,它提供了许多预先定义的CSS类和组件,可以帮助开发者快速构建响应式网站。在Bootstrap中,图片可以通过<img>标签插入到网页中,并使用相应的Bootstrap类进行样式化。那么Bootstrap图片怎么替换?

注意:在 v4.1 中,class 和 mixin 已被弃用,将在 v5 中完全删除。text-hide() 是一个用于隐藏文本的 CSS 类。

一、图片替换

利用.text-hide或 mixin 帮助将元素的文本内容替换为背景图像。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<h1 class="text-hide">Custom heading</h1>
<h1 class="text-hide">Custom heading</h1>
<h1 class="text-hide">Custom heading</h1>
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
// Usage as a mixin
.heading {
@include text-hide;
}
// Usage as a mixin .heading { @include text-hide; }
// Usage as a mixin
.heading {
@include text-hide;
}

二、维护标题

使用.text-hidebackground-image来维护标题标签的可访问性和 SEO 优势,但希望使用而不是文本。

Bootstrap图片替换

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<h1 class="text-hide" style="background-image: url('...');">Bootstrap</h1>
<h1 class="text-hide" style="background-image: url('...');">Bootstrap</h1>
<h1 class="text-hide" style="background-image: url('...');">Bootstrap</h1>
  • 广告合作

  • QQ群号:4114653

温馨提示:
1、本网站发布的内容(图片、视频和文字)以原创、转载和分享网络内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。邮箱:2942802716#qq.com(#改为@)。 2、本站原创内容未经允许不得转裁,转载请注明出处“站长百科”和原文地址。
Bootstrap图片替换
上一篇: Bootstrap浮动
Bootstrap图片替换
下一篇: Bootstrap交互方式