gpt4 book ai didi

javascript - Bootstrap 模式奇怪的问题

转载 作者:行者123 更新时间:2023-11-28 16:06:01 24 4
gpt4 key购买 nike

我有一些用 CSS3 制作的动画元素。 block 内有一个打开模态窗口的链接,但当模态窗口关闭时,动画元素仍处于“悬停”状态。

jsfiddle 中的示例:

<style>
.item-wrap {
position: relative;
height: 200px;
width: 200px;
background-color: black;
overflow: hidden;
}
.item-wrap p {
color: #fff;
text-align: center;
}
.item-wrap::before {
content: ' ';
position: absolute;
left: 0;
top: 0;
width: 0;
height: 100%;
opacity: 0.5;
-webkit-transition: width 0s ease, background-color 0.5s ease;
-moz-transition: width 0s ease, background-color 0.5s ease;
-o-transition: width 0s ease, background-color 0.5s ease;
transition: width 0s ease, background-color 0.5s ease;
}
.item-wrap::after {
content: ' ';
position: absolute;
right: 0;
top: 0;
width: 0;
height: 100%;
opacity: 0.5;
background-color: #fff;
transition: width 0.5s ease;
-webkit-transition: width 0.5s ease;
-moz-transition: width 0.5s ease;
-ms-transition: width 0.5s ease;
-o-transition: width 0.5s ease;
}

.item-wrap:hover::before {
width: 100%;
background-color: #fff;
transition: width 0.5s ease;
-webkit-transition: width 0.5s ease;
-moz-transition: width 0.5s ease;
-ms-transition: width 0.5s ease;
-o-transition: width 0.5s ease;
}
.item-wrap:hover::after {
width: 100%;
background-color: transparent;
transition: all 0s ease;
-webkit-transition: all 0s ease;
-moz-transition: all 0s ease;
-ms-transition: all 0s ease;
-o-transition: all 0s ease;
}
.item-wrap:hover .cover {
bottom: 0;
}
.cover a {
color: #fff;
}
.link1 {
position: absolute;
left: 20px;
top: 50%;
right: 20px;
}
.link2 {
position: absolute;
top: 50%;
right: 20px;
}
.item-wrap .cover {
position: absolute;
right: 0;
left: 0;
bottom: -100%;
width: 100%;
height: 100%;
transition: bottom 0.3s linear;
-webkit-transition: bottom 0.3s linear;
-moz-transition: bottom 0.3s linear;
-ms-transition: bottom 0.3s linear;
-o-transition: bottom 0.3s linear;
z-index: 10;
}
</style>
<div class="item">
<div class="item-wrap">
<p>Main content blah blah</p>
<div class="cover">
<a href="#" class="link1" data-toggle="modal" data-target="#myModal">Link1</a>
<a href="#" class="link2" data-toggle="modal" data-target="#myModal">Link2</a>
</div><!-- /.cover -->
</div><!-- /.item-wrap -->
</div><!-- /.item -->

<!-- Modal -->
<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">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>

示例 ins jsfiddle:https://jsfiddle.net/9objpv9x/

尝试悬停以查看动画和模态链接,然后单击“Link1”并关闭模态以查看接下来会发生什么。

我只是不知道从哪里开始挖掘。

最佳答案

实际上,“link1”处于“focus”状态,并且由于默认的 bootstrap css 属性显示了轮廓:

a:focus {
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}

要覆盖它,请在您的 css 中修改它。

a#id:focus {
outline: 0px;
}

要在模态关闭后移除焦点状态,我们需要在 jquery 中触发模态,而不是在 HTML 中使用“data-target”。

查看此 jsfiddle 链接。 Updated Code Fix

关于javascript - Bootstrap 模式奇怪的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39220076/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com