如何添加下一个和上一个按钮弹出?

时间:2016-01-22 07:36:00

标签: javascript jquery html css popup

我创建了2个popup.Inside弹出有两个超链接NEXT和PREVIOUS。如果任何用户点击任何超链接而不是下一个弹出窗口应该根据链接显示。请使用javascript / jquery以快速简单的方式实现此目的。

请帮帮我..

HTML

<a href="#openModal1">Open Modal1</a>

<div id="openModal1" class="modalDialog">


<div>  <div class="pop-header">
                        <a href="#"> &nbsp; < Previous </a>&nbsp; &nbsp; 
                         <a href="#">Next  ></a>
                        <a href="#close" title="Close" class="close">X</a>

                    </div>





                     <div class="row">  

                        <div class="main-content">
                            <div class="col-md-4" ><img src="http://preview.turbosquid.com/Preview/2014/07/11__06_24_26/OpenCardboardBox_2.jpg86a9e6a0-b552-4bfe-8923-71a6f174e5faOriginal.jpg" class="main-logo"/></div>
                             <div class="col-md-8"><h3>Lorem: Ipsum </h3><h4>Lorem: Ipsum</h4>is simply dummy text of the printing Lorem Ipsum is simply dummy text of the printing </div>
                         </div>

                    </div>

                        <div class="scroll-bar">
                        <div class="main-content">
                         <img src="http://99layer.com/wp-content/uploads/2013/07/Demo-website-Swiftlet2.jpg" class="main-img"/>
                        </div>
                         </div>


            </div>


</div>










<a href="#openModal2">Open Modal2</a>

<div id="openModal2" class="modalDialog">


<div>  <div class="pop-header">
                        <a href="#"> &nbsp; < Previous </a>&nbsp; &nbsp; 
                         <a href="#">Next  ></a>
                        <a href="#close" title="Close" class="close">X</a>

                    </div>





                     <div class="row">  

                        <div class="main-content">
                            <div class="col-md-4" ><img src="http://preview.turbosquid.com/Preview/2014/07/11__06_24_26/OpenCardboardBox_2.jpg86a9e6a0-b552-4bfe-8923-71a6f174e5faOriginal.jpg" class="main-logo"/></div>
                             <div class="col-md-8"><h3>Lorem: Ipsum </h3><h4>Lorem: Ipsum</h4>is simply dummy text of the printing Lorem Ipsum is simply dummy text of the printing </div>
                         </div>

                    </div>

                        <div class="scroll-bar">
                        <div class="main-content">
                         <img src="http://99layer.com/wp-content/uploads/2013/07/Demo-website-Swiftlet2.jpg" class="main-img"/>
                        </div>
                         </div>


            </div>


</div>

CSS

.pop-header
    {
         width: 100%;
         background-color: #E0E0E0;
         height: 60px;
         line-height:50px;

    }


    .pop-header > span{
        margin: 10px 20px;
        color:#000;

    }


.pop-header > a{
    text-decoration: none;
    color: #000;
}
    .modalDialog {
        position: fixed;
        font-family: Arial, Helvetica, sans-serif;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        background: rgba(0,0,0,0.8);
        z-index: 99999;
        opacity:0;
        -webkit-transition: opacity 400ms ease-in;
        -moz-transition: opacity 400ms ease-in;
        transition: opacity 400ms ease-in;
        pointer-events: none;
    }


    .modalDialog:target {
        opacity:1;
        pointer-events: auto;
    }

    .modalDialog > div {
        width: 600px;
        position: relative;
        margin: 2% auto;
        padding: 0;
        border-radius: 5px;
        background: #fff;
        height: 100%;
    }

    .close
    {
        float: right;
        padding: 20px;
    }

.main-content
{
    padding: 30px;
}
.main-logo  
{
    height: 130px; 
    width: 130px;

}

.main-img
{

    width: 100%;
    height: 400%;

}
.scroll-bar
{
    width: 98%;
    height: 100%;
    overflow-y: scroll;
    margin-top: 20px;

}

1 个答案:

答案 0 :(得分:2)

此示例无需使用JQuery或JavaScript即可运行。我相信你可以根据自己的需要进行调整。

        <!DOCTYPE html>
        <html>
        <head>
            <title>Creating a modal window with HTML5 &amp; CSS3</title>

            <style>
                .modalDialog {
                    position: fixed;
                    font-family: Arial, Helvetica, sans-serif;
                    top: 0;
                    right: 0;
                    bottom: 0;
                    left: 0;
                    background: rgba(0,0,0,0.8);
                    z-index: 99999;
                    opacity: 0;
                    -webkit-transition: opacity 400ms ease-in;
                    -moz-transition: opacity 400ms ease-in;
                    transition: opacity 400ms ease-in;
                    pointer-events: none;
                }

                    .modalDialog:target {
                        opacity: 1;
                        pointer-events: auto;
                    }

                    .modalDialog > div {
                        width: 400px;
                        position: relative;
                        margin: 10% auto;
                        padding: 5px 20px 13px 20px;
                        border-radius: 10px;
                        background: #fff;
                        background: -moz-linear-gradient(#fff, #999);
                        background: -webkit-linear-gradient(#fff, #999);
                        background: -o-linear-gradient(#fff, #999);
                    }

                .close {
                    background: #606061;
                    color: #FFFFFF;
                    line-height: 25px;
                    position: absolute;
                    right: -12px;
                    text-align: center;
                    top: -10px;
                    width: 24px;
                    text-decoration: none;
                    font-weight: bold;
                    -webkit-border-radius: 12px;
                    -moz-border-radius: 12px;
                    border-radius: 12px;
                    -moz-box-shadow: 1px 1px 3px #000;
                    -webkit-box-shadow: 1px 1px 3px #000;
                    box-shadow: 1px 1px 3px #000;
                }

                    .close:hover {
                        background: #00d9ff;
                    }
            </style>
        </head>

        <body>

            <a href="#openModal">Open Modal</a>
            <a href="#openModal2">Open Modal</a>

            <div id="openModal" class="modalDialog">
                <div>
                    <a href="#openModal2">Next</a>
                    <a href="#close" title="Close" class="close">X</a>
                    <h2>Modal Box 1</h2>
                    <p>This is a sample modal box that can be created using the powers of CSS3.</p>
                    <p>You could do a lot of things here like have a pop-up ad that shows when your website loads, or create a login/register form for users.</p>
                </div>
            </div>
            <div id="openModal2" class="modalDialog">
                <div>
                    <a href="#close" title="Close" class="close">X</a>
                    <a href="#openModal">Previous</a>
                    <h2>Modal Box 2</h2>

                    <p>This is a sample modal box that can be created using the powers of CSS3.</p>
                    <p>You could do a lot of things here like have a pop-up ad that shows when your website loads, or create a login/register form for users.</p>
                </div>
            </div>

        </body>
        </html>