0

我有一个教程中的代码。在这里,我想让我的缩略图在单击时显示一个动态模态,用户可以在其中编辑 onlick 模态内部的内容。我有一个类别列表,在我的缩略图<a href>中显示我的模式。我是 Wordpress 的初学者

我的问题:我真的不明白我在哪里可以创建我的模态?我知道关于我的模态的循环帖子,但是,它是一个帖子吗?我将在哪里创建我的动态模态?是通过邮寄吗?. 我应该创建一个帖子以及它如何链接以使其成为模态?我应该创建一个类别来知道这篇文章是模态的吗?

这是代码:

    <div class="row">
        <div  class="col-xs-4">
        <ul class="categories-filters">
            <?php 
                $args2 = array(
                    'exclude'   => array(6,3,2),
                    'order' =>  'DESC',
                    'title_li'  => __(''),
                    'posts_per_page' => '6',
                    'hierarchical'  => 'true'
                );
            wp_list_categories($args2);
            ?>
        </ul>
        </div>
        <div class="col-xs-8 bot">
            <div id="inside" class="row row-left">
            <?php if(have_posts()) : 
                $count = 0;
                while(have_posts()) : the_post();   ?>

                <div class="col-xs-8 col-box2">
                    <a href="#myModal-<? the_ID(); ?>" data-toggle="modal" ><?php the_post_thumbnail('thumbnail'); ?></a>
                </div>
                    <?php if($count==2) :
                        echo '</div>';
                        echo '<div id="inside" class="row row-left">';
                    endif; 
                    $count++; endwhile; 
                endif; 
                wp_reset_postdata();
                ?> 
            </div>
        </div>
    </div>

这是我的模态:

<div id="myModal-<? the_ID(); ?>" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-header">
        <h3 id="myModalLabel">
          <?php the_title();?>
        </h3>
        <p>
          <?php the_content();?>
        </p>
      </div>
      <div class="modal-body">
        <?php the_post_thumbnail(); ?>
      </div>
      <div class="modal-footer">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
      </div>
    </div>
4

1 回答 1

0

请参阅以下代码:

HTML 代码

<h1>Popup/Modal Windows without JavaScript</h1>
<div class="box">
    <a class="button" href="#popup1">Let me Pop up</a>
</div>

<div id="popup1" class="overlay">
    <div class="popup">
        <h2>Here Title of model</h2>
        <a class="close" href="#">&times;</a>
        <div class="content">
            <!-- your content to display in popup --> 
        </div>
    </div>
</div>

CSS 代码

body {
    font-family: Arial, sans-serif;
    background: url(http://www.shukatsu-note.com/wp-content/uploads/2014/12/computer-564136_1280.jpg) no-repeat;
    background-size: cover;
    height: 100vh;
}

h1 {
    text-align: center;
    font-family: Tahoma, Arial, sans-serif;
    color: #06D85F;
    margin: 80px 0;
}

.box {
    width: 40%;
    margin: 0 auto;
    background: rgba(255,255,255,0.2);
    padding: 35px;
    border: 2px solid #fff;
    border-radius: 20px/50px;
    background-clip: padding-box;
    text-align: center;
}

.button {
    font-size: 1em;
    padding: 10px;
    color: #fff;
    border: 2px solid #06D85F;
    border-radius: 20px/50px;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease-out;
}
.button:hover {
    background: #06D85F;
}

.overlay {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    transition: opacity 500ms;
    visibility: hidden;
    opacity: 0;
}
.overlay:target {
    visibility: visible;
    opacity: 1;
}

.popup {
    margin: 70px auto;
    padding: 20px;
    background: #fff;
    border-radius: 5px;
    width: 30%;
    position: relative;
    transition: all 5s ease-in-out;
}

.popup h2 {
    margin-top: 0;
    color: #333;
    font-family: Tahoma, Arial, sans-serif;
}
.popup .close {
    position: absolute;
    top: 20px;
    right: 30px;
    transition: all 200ms;
    font-size: 30px;
    font-weight: bold;
    text-decoration: none;
    color: #333;
}
.popup .close:hover {
    color: #06D85F;
}
.popup .content {
    max-height: 30%;
    overflow: auto;
}

@media screen and (max-width: 700px){
    .box{
        width: 70%;
    }
    .popup{
        width: 70%;
    }
}
于 2016-12-06T04:57:46.613 回答