0

0

详解Bootstrap缩略图组件及警示框组件_html/css_WEB-ITnose

php中文网

php中文网

发布时间:2016-06-24 11:19:32

|

1364人浏览过

|

来源于php中文网

原创

缩略图组件

缩略图在网站中最常用的就是产品列表页面,一行显示几张图片,有的在图片底下带有标题、描述内容、按钮等信息。bootstrap框架将这部分独立成一个模块组件,通过类名.thumbnail配合bootstrap的网格系统来实现。下面是bootstrap缩略图组件不同版本的源码文件:

LESS :  tbumbnails.less

SASS : _tbumbnails.scss

实现原理:

立即学习前端免费学习笔记(深入)”;

布局的实现主要依靠于bootstrap框架的网格系统,下面是缩略图对应的样式

.thumbnail {  display: block;  padding: 4px;  margin-bottom: 20px;  line-height: 1.42857143;  background-color: #fff;  border: 1px solid #ddd;  border-radius: 4px;  -webkit-transition: all .2s ease-in-out;          transition: all .2s ease-in-out;}.thumbnail > img,.thumbnail a > img {  margin-right: auto;  margin-left: auto;}a.thumbnail:hover,a.thumbnail:focus,a.thumbnail.active {  border-color: #428bca;}.thumbnail .caption {  padding: 9px;  color: #333;}

来看一个例子:

<div class="container">      <div class="row">          <div class="col-md-3">              <a herf="#" class="thumbnail">                  <img  src="img/1.jpg"   style="max-width:90%" alt="详解Bootstrap缩略图组件及警示框组件_html/css_WEB-ITnose" >              </a>          </div>          <div class="col-md-3">              <a herf="#" class="thumbnail">                  <img  src="img/2.jpg"   style="max-width:90%" alt="详解Bootstrap缩略图组件及警示框组件_html/css_WEB-ITnose" >              </a>          </div>          <div class="col-md-3">              <a herf="#" class="thumbnail">                  <img  src="img/3.jpg"   style="max-width:90%" alt="详解Bootstrap缩略图组件及警示框组件_html/css_WEB-ITnose" >              </a>          </div>          <div class="col-md-3">              <a herf="#" class="thumbnail" >                  <img  src="img/4.jpg"   style="max-width:90%" alt="详解Bootstrap缩略图组件及警示框组件_html/css_WEB-ITnose" >              </a>          </div>      </div>  </div>

效果如下:

可以用火狐响应式设计视图查看

在仅有缩略图的基础上,添加一个类名为.caption的div容器,在这个容器中放置其他内容,如:标题,文本描述,按钮等

<div class="container">      <div class="row">          <div class="col-md-3">              <a href="#" class="thumbnail">                  <img  src="img/1.jpg"   style="max-width:90%" alt="详解Bootstrap缩略图组件及警示框组件_html/css_WEB-ITnose" >              </a>              <div class="caption">                  <h3>这里是图文标题1111</h3>                  <p>这里是描述内容这里是描述内容这里是描述内容这里是描述内容这里是描述内容这里是描述内容这里是描述内容</p>                  <a  href="#" class="btn btn-primary">开始学习</a>                  <a  href="#" class="btn btn-info">正在学习</a>              </div>          </div>          <div class="col-md-3">              <a href="#" class="thumbnail">                  <img  src="img/2.jpg"   style="max-width:90%" alt="详解Bootstrap缩略图组件及警示框组件_html/css_WEB-ITnose" >              </a>              <div class="caption">                  <h3>这里是图文标题2222</h3>                  <p>这里是描述内容2222这里是描述内容22222这里是描述内容22222这里是描述内容222这里是描述内容2222</p>                  <a href="#" class="btn btn-primary">开始学习</a>                  <a  href="#" class="btn btn-info">正在学习</a>              </div>          </div>          <div class="col-md-3">              <a href="#" class="thumbnail">                  <img  src="img/3.jpg"   style="max-width:90%" alt="详解Bootstrap缩略图组件及警示框组件_html/css_WEB-ITnose" >              </a>              <div class="caption">                  <h3>这里是图文标题3333</h3>                  <p>这里是描述内容3333这里是描述内容3333这里是描述内容33333这里是描述内容222这里是描述内容3333</p>                  <a href="#" class="btn btn-primary">开始学习</a>                  <a  href="#" class="btn btn-info">正在学习</a>              </div>          </div>          <div class="col-md-3">              <a href="#" class="thumbnail">                  <img  src="img/4.jpg"   style="max-width:90%" alt="详解Bootstrap缩略图组件及警示框组件_html/css_WEB-ITnose" >              </a>              <div class="caption">                  <h3>这里是图文标题4444</h3>                  <p>这里是描述内容4444这里是描述内容4444这里是描述内容4444这里是描述内容4444这里是描述内容4444</p>                  <a href="#" class="btn btn-primary">开始学习</a>                  <a  href="#" class="btn btn-info">正在学习</a>              </div>          </div>      </div>  </div>

 

警示框组件

影谱
影谱

汉语电影AI辅助创作平台

下载

bootstrap框架通过.alert样式来实现警示框效果,在默认情况下,bootstrap提供了四种不同的警示框效果:

1、成功警示框:提示用户操作成功,在.alert的基础上追加.alert-success样式;

2、信息警告框:给用户提供提示信息,在.alert的基础上追加.alert-info样式;

3、警告警示框:提供警告信息,在.alert的基础上追加.alert-warning样式;

4、错误警示框:提示用户操作错误,在.alert的基础上追加.alert-danger样式;

其中,.alert样式主要设置了警示框的背景色、边框,圆角,文字颜色,此外还对h4、p、ul及.alert-link做了样式上的处理,下面是css源码:

.alert {  padding: 15px;  margin-bottom: 20px;  border: 1px solid transparent;  border-radius: 4px;}.alert h4 {  margin-top: 0;  color: inherit;}.alert .alert-link {  font-weight: bold;}.alert > p,.alert > ul {  margin-bottom: 0;}.alert > p + p {  margin-top: 5px;}

.alert-success {  color: #3c763d;  background-color: #dff0d8;  border-color: #d6e9c6;}.alert-success hr {  border-top-color: #c9e2b3;}.alert-success .alert-link {  color: #2b542c;}.alert-info {  color: #31708f;  background-color: #d9edf7;  border-color: #bce8f1;}.alert-info hr {  border-top-color: #a6e1ec;}.alert-info .alert-link {  color: #245269;}.alert-warning {  color: #8a6d3b;  background-color: #fcf8e3;  border-color: #faebcc;}.alert-warning hr {  border-top-color: #f7e1b5;}.alert-warning .alert-link {  color: #66512c;}.alert-danger {  color: #a94442;  background-color: #f2dede;  border-color: #ebccd1;}.alert-danger hr {  border-top-color: #e4b9c0;}.alert-danger .alert-link {  color: #843534;}

例如:

<div class="alert alert-success" role="alert">恭喜你操作成功!</div>    <div class="alert alert-info" role="alert">请输入正确的密码</div>    <div class="alert alert-warning" role="alert">你已经操作失败两次,还有最后一次机会</div>    <div class="alert alert-danger" role="alert">对不起,你的密码输入有误!</div>

 

可关闭的警示框

1、在默认的警示框的容器上追加一个.alert-dismissable类名

2、在button标签中添加.close,实现警告框的关闭按钮

3、确保关闭按钮元素上设置了自定义属性data-dismiss=”alert“(关闭警示框需要通过js来检测该属性,从而控制警示框的关闭)

例子:

<div class="alert alert-success alert-dismissable" role="alert">        <button class="close" type="button" data-dismiss="alert">&times;</button>        恭喜你操作成功!    </div>    <div class="alert alert-info alert-dismissable"role="alert">         <button class="close" type="button" data-dismiss="alert">&times;</button>        请输入正确的密码    </div>    <div class="alert alert-warning alert-dismissable"  role="alert">        <button class="close" type="button" data-dismiss="alert">&times;</button>        你已经操作失败两次,还有最后一次机会    </div>    <div class="alert alert-danger alert-dismissable" role="alert">         <button class="close" type="button" data-dismiss="alert">&times;</button>        对不起,你的密码输入有误!    </div>

 

警示框的链接

有时候需要在警示框中加入链接,告诉用户跳转到新的页面,bootstrap框架中对警示框的链接做了高亮处理。给警告框加的链接添加一个为.alert-link的类名,下面是alert-link的css样式

.alert .alert-link {  font-weight: bold;}/*不同类型警示框中链接的文本颜色*/.alert-success .alert-link {  color: #2b542c;}.alert-info .alert-link {  color: #245269;}.alert-warning .alert-link {  color: #66512c;}.alert-danger .alert-link {  color: #843534;}

例子:

<div class="alert alert-success " role="alert">        <strong>Well done!</strong>        You successfully read        <a href="#" class="alert-link">this important alert message</a>    </div>    <div class="alert alert-info" role="alert">        <strong>Well done!</strong>        You successfully read        <a href="#" class="alert-link">this important alert message</a>    </div>    <div class="alert alert-warning " role="alert">        <strong>Well done!</strong>        You successfully read        <a href="#" class="alert-link">this important alert message</a>    </div>    <div class="alert alert-danger" role="alert">        <strong>Well done!</strong>        You successfully read        <a href="#" class="alert-link">this important alert message</a> </div>

相关文章

HTML速学教程(入门课程)
HTML速学教程(入门课程)

HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!

下载

本站声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热门AI工具

更多
DeepSeek
DeepSeek

幻方量化公司旗下的开源大模型平台

豆包大模型
豆包大模型

字节跳动自主研发的一系列大型语言模型

通义千问
通义千问

阿里巴巴推出的全能AI助手

腾讯元宝
腾讯元宝

腾讯混元平台推出的AI助手

文心一言
文心一言

文心一言是百度开发的AI聊天机器人,通过对话可以生成各种形式的内容。

讯飞写作
讯飞写作

基于讯飞星火大模型的AI写作工具,可以快速生成新闻稿件、品宣文案、工作总结、心得体会等各种文文稿

即梦AI
即梦AI

一站式AI创作平台,免费AI图片和视频生成。

ChatGPT
ChatGPT

最最强大的AI聊天机器人程序,ChatGPT不单是聊天机器人,还能进行撰写邮件、视频脚本、文案、翻译、代码等任务。

相关专题

更多
pixiv网页版官网登录与阅读指南_pixiv官网直达入口与在线访问方法
pixiv网页版官网登录与阅读指南_pixiv官网直达入口与在线访问方法

本专题系统整理pixiv网页版官网入口及登录访问方式,涵盖官网登录页面直达路径、在线阅读入口及快速进入方法说明,帮助用户高效找到pixiv官方网站,实现便捷、安全的网页端浏览与账号登录体验。

616

2026.02.13

微博网页版主页入口与登录指南_官方网页端快速访问方法
微博网页版主页入口与登录指南_官方网页端快速访问方法

本专题系统整理微博网页版官方入口及网页端登录方式,涵盖首页直达地址、账号登录流程与常见访问问题说明,帮助用户快速找到微博官网主页,实现便捷、安全的网页端登录与内容浏览体验。

194

2026.02.13

Flutter跨平台开发与状态管理实战
Flutter跨平台开发与状态管理实战

本专题围绕Flutter框架展开,系统讲解跨平台UI构建原理与状态管理方案。内容涵盖Widget生命周期、路由管理、Provider与Bloc状态管理模式、网络请求封装及性能优化技巧。通过实战项目演示,帮助开发者构建流畅、可维护的跨平台移动应用。

91

2026.02.13

TypeScript工程化开发与Vite构建优化实践
TypeScript工程化开发与Vite构建优化实践

本专题面向前端开发者,深入讲解 TypeScript 类型系统与大型项目结构设计方法,并结合 Vite 构建工具优化前端工程化流程。内容包括模块化设计、类型声明管理、代码分割、热更新原理以及构建性能调优。通过完整项目示例,帮助开发者提升代码可维护性与开发效率。

20

2026.02.13

Redis高可用架构与分布式缓存实战
Redis高可用架构与分布式缓存实战

本专题围绕 Redis 在高并发系统中的应用展开,系统讲解主从复制、哨兵机制、Cluster 集群模式及数据分片原理。内容涵盖缓存穿透与雪崩解决方案、分布式锁实现、热点数据优化及持久化策略。通过真实业务场景演示,帮助开发者构建高可用、可扩展的分布式缓存系统。

54

2026.02.13

c语言 数据类型
c语言 数据类型

本专题整合了c语言数据类型相关内容,阅读专题下面的文章了解更多详细内容。

29

2026.02.12

雨课堂网页版登录入口与使用指南_官方在线教学平台访问方法
雨课堂网页版登录入口与使用指南_官方在线教学平台访问方法

本专题系统整理雨课堂网页版官方入口及在线登录方式,涵盖账号登录流程、官方直连入口及平台访问方法说明,帮助师生用户快速进入雨课堂在线教学平台,实现便捷、高效的课程学习与教学管理体验。

15

2026.02.12

豆包AI网页版入口与智能创作指南_官方在线写作与图片生成使用方法
豆包AI网页版入口与智能创作指南_官方在线写作与图片生成使用方法

本专题汇总豆包AI官方网页版入口及在线使用方式,涵盖智能写作工具、图片生成体验入口和官网登录方法,帮助用户快速直达豆包AI平台,高效完成文本创作与AI生图任务,实现便捷智能创作体验。

598

2026.02.12

PostgreSQL性能优化与索引调优实战
PostgreSQL性能优化与索引调优实战

本专题面向后端开发与数据库工程师,深入讲解 PostgreSQL 查询优化原理与索引机制。内容包括执行计划分析、常见索引类型对比、慢查询优化策略、事务隔离级别以及高并发场景下的性能调优技巧。通过实战案例解析,帮助开发者提升数据库响应速度与系统稳定性。

56

2026.02.12

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号