css - 使用 Struts2 和 bootstrap 以模态方式打开图像

标签 css twitter-bootstrap jsp struts2 modal-dialog

我想尝试以模态方式点击打开我网站上的所有图像。我正在使用 Struts2、Bootstrap。请告诉我正确的方法,一些例子?

这是我的代码:

 <div class="row">
    <s:iterator value="galleryList" var="galleryTemp">
       <div class="col-xs-5 col-md-3">
         <div class="thumbnail">
          <a href=""><img src='userfiles/images/<s:property value="%{#galleryTemp.imageName}" />'  class="thumbnail"  data-toggle="modal" data-target="#myModal<s:property value="%{#galleryTemp.id}" />"  alt="body img" />
            </a>
        <div class="modal fade" id="myModal<s:property value="%{#galleryTemp.id}" />" tabindex="-1" role="image" aria-labelledby="myModalLabel" aria-hidden="true">

         <img src='userfiles/images/<s:property value="%{#galleryTemp.imageName}" />' class="thumbnail" data-toggle="modal" data-target="#myModal" alt="body img" />
           </div>
     <div class="caption">
<center><h4><s:property value="%{#galleryTemp.description}" escapeHtml="false"/></h4>                   </center>
    </div>
   </div>    
 </div> 
</s:iterator>
</div>

最佳答案

试试这段代码

 <div class="row">
    <s:iterator value="galleryList" var="galleryTemp">
       <div class="col-xs-5 col-md-3">
         <div class="thumbnail">
          <a href="#"><img src='userfiles/images/<s:property value="%{#galleryTemp.imageName}" />'  class="thumbnail"  data-toggle="modal" data-target="#myModal<s:property value="%{#galleryTemp.id}" />"  alt="body img" /></a>
         </div>
         <div class="modal fade" id="myModal<s:property value="%{#galleryTemp.id}" />" tabindex="-1" role="image" aria-labelledby="myModalLabel" aria-hidden="true">
          <div class="modal-dialog">
           <div class="modal-content">
            <div class="modal-header">
             <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
             <div class="caption">
             <center><h4><s:property value="%{#galleryTemp.description}" escapeHtml="false"/></h4>                   </center>
             </div>
            </div>
            <div class="modal-body">
             <img src='userfiles/images/<s:property value="%{#galleryTemp.imageName}" />' class="thumbnail" data-toggle="modal" data-target="#myModal" alt="body img" />
            </div>
           </div>    
          </div> 
       </div>
    </s:iterator>
</div>

关于css - 使用 Struts2 和 bootstrap 以模态方式打开图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23033154/

相关文章:

javascript - 我的旋转木马在循环到第 3 张幻灯片时会放大和缩小?

javascript - 单选按钮的onchange

jsp - 避免javascript或php的时间间隔后的sendRedirect

html - 为什么网格不会将标有 "."的单元格留空?

javascript - 纯 JS 滑动菜单,能够关闭它 "on click outside of the menu"

jquery - Twitter bootstrap 显示来自另一个模态的模态

java - 我如何以 struts 迭代器生成的单个表单调用多个操作

html - 是否可以使用文本溢出 :ellipsis on multiline text?

html - Firefox 和 IE9 溢出时对滚动条的不同处理 :auto

javascript - 如何使用日期选择器将明天的日期设置为默认日期?