boostrap笔记(轮播、提示框、弹出框、模态框)
程序员文章站
2022-05-31 11:46:37
...
<!DOCTYPE html>
<html>
<head>
<title>Bootstrap 实例</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/popper.js/1.12.5/umd/popper.min.js"></script>
<script src="https://cdn.bootcss.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<style>
/* Make the image fully responsive */
.carousel-inner img {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div id="demo" class="carousel slide" data-ride="carousel">
<!-- 指示符 -->
<ul class="carousel-indicators">
<li data-target="#demo" data-slide-to="0" class="active"></li>
<li data-target="#demo" data-slide-to="1"></li>
<li data-target="#demo" data-slide-to="2"></li>
</ul>
<!-- 轮播图片 -->
<div class="carousel-inner">
<div class="carousel-item active">
<img src="http://static.runoob.com/images/mix/img_fjords_wide.jpg">
<div class="carousel-caption">
<h1>添加文字描述</h1>
<p>文字描述</p>
</div>
</div>
<div class="carousel-item">
<img src="http://static.runoob.com/images/mix/img_nature_wide.jpg">
</div>
<div class="carousel-item">
<img src="http://static.runoob.com/images/mix/img_mountains_wide.jpg">
</div>
</div>
<!-- 左右切换按钮 -->
<a class="carousel-control-prev" href="#demo" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
</a>
<a class="carousel-control-next" href="#demo" data-slide="next">
<span class="carousel-control-next-icon"></span>
</a>
</div>
<br>
<h3>提示框实例</h3>
<a href="#" data-toggle="tooltip" data-placement="bottom" title="我是提示内容!">鼠标移动到这</a>
<br>
<a href="#" data-toggle="popover" data-placement="right" title="弹出标题" data-content="弹出内容!">鼠标点击这里</a>
<br><br>
<div>
<h1>模态框实例</h1>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#Mymodal">
打开模态框:
</button>
<div class="modal fade" id="Mymodal">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">模态框头部</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
模态框内容..
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip();
});
$(document).ready(function(){
$('[data-toggle="popover"]').popover();
});
</script>
</body>
</html>
用bootstrap实现图片轮播比原生js/css实现代码更简洁,逻辑更清楚
carrousel-caption:添加文字描述
data-placement:指定弹出框位置
data-toggle="tooltip" :创建提示框
data-toggle="popover":创建弹出框
title :弹出框的标题
data-content:弹出框的文本内容
弹出框要写在 jQuery 的初始化代码里: 然后在指定的元素上调用 popover() 方法。
data-trigger="focus" :设置在鼠标点击元素外部区域来关闭弹出框
data-trigger="hover":实现在鼠标移动到元素上显示,移除后消失的效果
上一篇: 59.弹出框与模糊的背景特效
下一篇: mapbox点击图片弹出对话框
推荐阅读
-
boostrap模态框二次弹出清空原有内容的方法
-
整理:手机端弹出提示框,使用的bootstrap中的模态框(modal,弹出层),比kendo弹出效果好
-
Bootstrap4 轮播+模态框+提示框+弹出框
-
整理关于Bootstrap模态弹出框的慕课笔记
-
boostrap模态框二次弹出清空原有内容的方法
-
boostrap笔记(轮播、提示框、弹出框、模态框)
-
bootstrap添加模态窗后,再弹出消息提示框后,原先的滚动条被吃掉了_html/css_WEB-ITnose
-
jQuery学习笔记(2)--用jquery实现各种模态提示框代码及项目构架_jquery
-
bootstrap添加模态窗后,再弹出消息提示框后,原先的滚动条被吃掉了_html/css_WEB-ITnose
-
Bootstrap4 轮播+模态框+提示框+弹出框