繁体   English   中英

单击框弹出图像和生物

[英]Click on box for popup image and bio

我正在WordPress中建立网站,但无法使用我的JavaScript。

我试图产生与此类似的效果: 单击此处 ,当您单击顾问的框时,将弹出图像和简介。

我已经制作了JavaScript并将其全部链接起来-但是无法加载该框。

*/

$(document).ready(function() {

/*

*/
$('.classes a').click(function(e) {

    e.preventDefault();

    // Get the dimensions of the user's screen
    var maskHeight = $(document).height();
    var maskWidth = $(window).width();

    // Set the mask overlay to fill the entire screen
    $('.mask').css({'width':maskWidth,'height':maskHeight});

    // Fade in the mask overlay
    $('.mask').fadeTo(600, 0.7);

    // Get the dimensions of the user's browser
    var winHeight = $(window).height();
    var winWidth = $(window).width();

    // Set the bio pop-up to be in the middle of the screen
    $('.classes-bio').css('top', winHeight/2-$('.classes-bio').height()/2);
    $('.classes-bio').css('left', winWidth/2-$('.classes-bio').width()/2);

    // Fade in the bio pop-up
    $(this).parent('.classes').find('.classes-bio').delay(610).fadeIn(600);
});

// Click the mask or close button to fade out the pop-up and the mask
$('.mask, img.close-button').click(function(e) {

    $('.classes-bio, .video-box').fadeOut(600);

    $('.mask').delay(610).fadeOut(600);
});

/*

CSS:

.classes {
margin-bottom: 75px;
}

.classes {
width: 450px;
float: left;
margin: 10px 8px 0 0;
}

.classes:nth-child(4n+4) {
margin-right: 0;
}

.classes a {
text-decoration: none;
}

.classes h2,
.classes .classes-bio h2 {
font-weight: 700;
font-size: 1.5em;
text-transform: none;
margin: 15px 0 5px 12px;
}

.classes .classes-bio p {
color: #666;
line-height: 21px;
margin: 0 70px 18px 70px;
}

.classes .classes-bio p strong {
font-weight: 700;
}


.classes a.read-more {
color: #D1883E;
display: block;
margin: 12px 0 0 0px;
}

.classes a.read-more:hover {
text-decoration: underline;
}

.classes .classes-bio {
position: fixed;
width: 600px;
height: 90%;
display: none;
z-index: 9998;
padding-bottom: 10px;
background-color: #eaeaea;
}

.classes .classes-bio .close-button {
position: absolute;
top: -17px;
right: -17px;
z-index: 9999;
cursor: pointer;
}

.classes .classes-bio img.profile {
width: 238px;
margin: 25px 181px 8px;
}

.classes .classes-bio h2 {
text-align: center;
margin-bottom: 6px;
}

.classes .classes-bio p.job-title {
font-size: 1.1em;
margin-bottom: 28px;
}

.classes .classes-bio p {
font-size: 0.9em;
color: #000;
text-align: center;
}

/*

.mask {
position: absolute;
left: 0;
top: 0;
display: none;
z-index: 9997;
background-color: #000;
}

看一下您提供的JavaScript代码,我可以立即看到* /的第一行正在阻止JavaScript正常执行。 还要删除/ *最后一行

尝试修复该页面上的所有代码错误。 我进行了扫描,发现您的页面有35个错误http://validator.w3.org/check?uri=http://www.scpolechamps.co.uk/classes-2/

信不信由你,标记中最简单的错误可能会阻止JavaScript正常运行。

例如,在该页面上,您具有以下内容:

<img style="border: 5px solid black;" "padding-bottom:10px;" alt="" src="/wp-content/themes/tigertone/images/pole.png" width="447" height="193" />

它应该是:

<img src="/wp-content/themes/tigertone/images/pole.png" height="193" width="447" style="border:5px solid black;padding-bottom:10px" alt="Pole Dancing">

您有style="border: 5px solid black;" "padding-bottom:10px;" style="border: 5px solid black;" "padding-bottom:10px;" 应该放在一起的style="border:5px solid black;padding-bottom:10px" ,例如style="border:5px solid black;padding-bottom:10px"

另外,您应该避免使用内联CSS。 要赋予图像某种样式,请将CSS代码放置在外部CSS文件中,并使用与您的图像相对应的适当CSS ID或CLASS名称。 它将以多种方式使您和您的访客受益。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM