bootstrap之data-dismiss作用

data-dismiss是bootstrap里自定义的属性,给一个元素data-dimiss属性的话,可以通过点击该元素达到让目标消失的效果。
例如:当点击按钮时,直接关闭外层alert

× Warning! Better check yourself, you're not looking too good.

这里是引用https://www.jianshu.com/p/ca2c4c1faac1
原文查看:

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
`data-toggle` 和 `data-target` 是Bootstrap中的两个HTML属性,用于定义一个触发器和一个目标元素。 `data-toggle` 属性指定了触发器的类型,可以是 `modal`、`dropdown`、`tab` 等。它告诉Bootstrap该元素是用来触发一个特定的功能。 `data-target` 属性指定了目标元素的选择器或ID。当触发器被触发时,Bootstrap会根据 `data-target` 属性查找目标元素,然后对其进行相应的操作,比如展示一个模态框。 举个例子,如果你想在一个按钮上添加模态框功能,你可以这样写: ```html <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal"> 打开模态框 </button> <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h4 class="modal-title" id="myModalLabel">模态框标题</h4> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"> 模态框内容 </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button> <button type="button" class="btn btn-primary">保存</button> </div> </div> </div> </div> ``` 这个例子中,`data-toggle="modal"` 和 `data-target="#myModal"` 指定了该按钮是一个触发模态框的按钮,并且对应的目标元素是 ID 为 `myModal` 的 `div` 元素。当按钮被点击时,Bootstrap会自动展示这个模态框。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值