简体   繁体   English

单击框弹出图像和生物

[英]Click on box for popup image and bio

I am building a website in WordPress and can't get my JavaScript to work. 我正在WordPress中建立网站,但无法使用我的JavaScript。

I am trying to produce a similar effect to this: Click here where when you click on the consultant's box an image and bio pops up. 我试图产生与此类似的效果: 单击此处 ,当您单击顾问的框时,将弹出图像和简介。

I have produced the JavaScript and linked it all up - but the box won't load up. 我已经制作了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: 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;
}

Taking a look at your provided JavaScript code I can immediately see that the first line of * / is preventing the JavaScript from executing properly. 看一下您提供的JavaScript代码,我可以立即看到* /的第一行正在阻止JavaScript正常执行。 Also remove the very last line of / * 还要删除/ *最后一行

Try fixing up all the code errors on that page. 尝试修复该页面上的所有代码错误。 I ran a scan and found your page to have 35 errors http://validator.w3.org/check?uri=http://www.scpolechamps.co.uk/classes-2/ 我进行了扫描,发现您的页面有35个错误http://validator.w3.org/check?uri=http://www.scpolechamps.co.uk/classes-2/

Believe it or not, the simplest error in your markup can prevent JavaScript from properly working. 信不信由你,标记中最简单的错误可能会阻止JavaScript正常运行。

For example on that page you have the following: 例如,在该页面上,您具有以下内容:

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

It should be: 它应该是:

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

You had style="border: 5px solid black;" "padding-bottom:10px;" 您有style="border: 5px solid black;" "padding-bottom:10px;" style="border: 5px solid black;" "padding-bottom:10px;" where it should have been all together like style="border:5px solid black;padding-bottom:10px" 应该放在一起的style="border:5px solid black;padding-bottom:10px" ,例如style="border:5px solid black;padding-bottom:10px"

Adding on, you should avoid using inline CSS. 另外,您应该避免使用内联CSS。 To give the image some style, place the CSS code in an external CSS file with the appropriate CSS ID or CLASS name that corresponds to your image. 要赋予图像某种样式,请将CSS代码放置在外部CSS文件中,并使用与您的图像相对应的适当CSS ID或CLASS名称。 It will benefit you and your visitors in many ways. 它将以多种方式使您和您的访客受益。

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

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