gpt4 book ai didi

javascript - 为什么单击图标时模态不启动?

转载 作者:行者123 更新时间:2023-11-30 19:38:33 25 4
gpt4 key购买 nike

我一直在尝试各种方法来激活模式,从 javascript 到直接调用模式都没有成功。该页面所做的只是允许单击,然后什么都不做。

我试过从 javascript 文件调用模态,我试过直接从div调用它,我试过 href 的 javascript,我试过检查语法或拼写错误,我试过在 div、ancor、image 和 button 标签之间交换。

<div class="child flex-child">
<div class="profile-btn">
<div class="profile-bubble-parent" data-target="#profileModal" data-toggle="modal" onclick="openProfileModal();" >
<img class="profile-bubble" src="assets/img/user.ico">
</div>
</div>
<div class="modal fade" id="profileModal" tabindex="-1" role="dialog" aria-labelledby="profileModal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="title-pen"> User Profile <span>UI</span></h1>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
</div>
<div class="modal-body">
<div class="box">
<div class="content">
<div class="user-profile">
<img class="avatar" src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcTF_erFD1SeUnxEpvFjzBCCDxLvf-wlh9ZuPMqi02qGnyyBtPWdE-3KoH3s" alt="Ash" />
<div class="username">
Will Smith
</div>
<div class="bio">
Senior UI Designer
</div>
<div class="description">
I use to design websites and applications
for the web.
</div>
<ul class="data">
<li>
<span class="entypo-heart"> 127</span>
</li>
<li>
<span class="entypo-eye"> 853</span>
</li>
<li>
<span class="entypo-user"> 311</span>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">

</div>
</div>
</div>
</div>

js文件有:

function openProfileModal(){
setTimeout(function(){
$('#profileModal').modal('show');
}, 230);

}

CSS:



/*===================================================================================
======================================PROFILE========================================*/

.profile-bubble {
height: 55px;
width: 55px;
border-radius: 50%;
}

.title-pen {
color: #333;
font-family: "Coda", sans-serif;
text-align: center;
}
.title-pen span {
color: #55acee;
}

.user-profile {
margin: auto;
width: 25em;
height: 11em;
background: #fff;
border-radius: .3em;
}

.user-profile .username {
margin: auto;
margin-top: -4.40em;
margin-left: 5.80em;
color: #658585;
font-size: 1.53em;
font-family: "Coda", sans-serif;
font-weight: bold;
}
.user-profile .bio {
margin: auto;
display: inline-block;
margin-left: 10.43em;
color: #e76043;
font-size: .87em;
font-family: "varela round", sans-serif;
}
.user-profile > .description {
margin: auto;
margin-top: 1.35em;
margin-right: 4.43em;
width: 14em;
color: #c0c5c5;
font-size: .87em;
font-family: "varela round", sans-serif;
}
.user-profile > img.avatar {
padding: .7em;
margin-left: .3em;
margin-top: .3em;
height: 6.23em;
width: 6.23em;
border-radius: 18em;
}

.user-profile ul.data {
margin: 2em auto;
height: 3.70em;
background: #4eb6b6;
text-align: center;
border-radius: 0 0 .3em .3em;
}
.user-profile li {
margin: 0 auto;
padding: 1.30em;
width: 33.33334%;
display: table-cell;
text-align: center;
}

.user-profile span {
font-family: "varela round", sans-serif;
color: #e3eeee;
white-space: nowrap;
font-size: 1.27em;
font-weight: bold;
}
.user-profile span:hover {
color: #daebea;
}

/*===================================================================================
======================================MODAL========================================*/

.modal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
padding-top: 100px; /* Location of the box */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}

.modal-content {
background-color: #fefefe;
margin: auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
}


.close {
color: #aaaaaa;
float: right;
font-size: 28px;
font-weight: bold;
}

.close:hover,
.close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
}

结果应该是内容的弹出模式。

最佳答案

首先,我将模态主体移到标签外,并给它一个 id,profileModal。接下来,我知道它起作用了。

关于javascript - 为什么单击图标时模态不启动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55678356/

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