我如何在我的 Jekyll 网站上的模态中放置多个图像?
How can I place multiple images in a modal on my Jekyll site?
我正在使用修改后的 Bootstrap 主题 (specifically this theme) 和 Jekyll 构建一个网站。这是我第一次使用 Jekyll,到目前为止一切进展顺利,直到这让我感到难过。
就像我在上面链接的 bootstrap 主题一样,我有一个投资组合部分,它打开了一个模式,我想在其中包含一些照片和一段文字。到目前为止,我已经让模态 post 的其他元素按照我希望的方式工作,但无法找到添加多个图像的方法。
这是我的投资组合模式html
{% for post in site.posts %}
<div class="portfolio-modal modal fade" id="portfolioModal-{{ post.modal-id }}" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="close-modal" data-dismiss="modal">
<div class="lr">
<div class="rl">
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2">
<div class="modal-body">
<!-- Project Details Go Here -->
<h2>{{ post.title }}</h2>
<p class="item-intro text-muted"> {{ post.subheading }} </p>
<p>{{ post.description }}</p>
<img class="img-responsive" src="img/portfolio/{{ post.img }}">
<ul class="list-inline">
<li>Date: July 2014</li>
<li>Location: {{ post.location }} </li>
<li>Category: {{ post.category }} </li>
</ul>
<button type="button" class="btn btn-primary" data-dismiss="modal"><i class="fa fa-times"></i> Close Project</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endfor %}
这是我的模态的封面post
---
layout: post
modal-id: 1
title: Post title
date: 2017-01-06
location: Project location
img: img.jpg
category: Post category
alt: image-alt
description: Post description
---
因此,我不确定如何为每个 post 添加多张图片。非常感谢任何帮助!
构建 sequence/array/list 图像和 alt 标签以替换 Front Matter 中的 img:
和 alt:
,然后遍历它们。没有别的了。
示例序列:
images-array:
- image: image-1.jpg
alt: This is some alt text
- image: image-2.jpg
alt: This is some alt text
- image: image-3.jpg
alt: This is some alt text
更新前题:
---
layout: post
modal-id: 1
title: Post title
date: 2017-01-06T00:00:00.000Z
location: Project location
category: Post category
description: Post description
images-array:
- image: image-1.jpg
alt: This is some alt text
- image: image-2.jpg
alt: This is some alt text
- image: image-3.jpg
alt: This is some alt text
---
For循环:
{% for item in post.images-array %}
<img class="img-responsive" src="img/portfolio/{{ item.image }}" alt="{{ item.alt }}">
{% endfor %}
For 循环使用 Bootstrap 列:
{% for post in site.posts %}
<div class="portfolio-modal modal fade" id="portfolioModal-{{ post.modal-id }}" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="close-modal" data-dismiss="modal">
<div class="lr">
<div class="rl"></div>
</div>
</div>
<div class="modal-body">
<h2>{{ post.title }}</h2>
<p class="item-intro text-muted"> {{ post.subheading }} </p>
<p>{{ post.description }}</p>
{% for item in post.images-array %}
<div class="col-sm-4">
<img class="img-responsive" src="img/portfolio/{{ item.image }}" alt="{{ item.alt }}">
</div>
{% endfor %}
<ul class="list-inline">
<li>Date: July 2014</li>
<li>Location: {{ post.location }} </li>
<li>Category: {{ post.category }} </li>
</ul>
<button type="button" class="btn btn-primary" data-dismiss="modal"><i class="fa fa-times"></i> Close Project</button>
</div>
</div>
</div>
</div>
{% endfor %}
我正在使用修改后的 Bootstrap 主题 (specifically this theme) 和 Jekyll 构建一个网站。这是我第一次使用 Jekyll,到目前为止一切进展顺利,直到这让我感到难过。
就像我在上面链接的 bootstrap 主题一样,我有一个投资组合部分,它打开了一个模式,我想在其中包含一些照片和一段文字。到目前为止,我已经让模态 post 的其他元素按照我希望的方式工作,但无法找到添加多个图像的方法。
这是我的投资组合模式html
{% for post in site.posts %}
<div class="portfolio-modal modal fade" id="portfolioModal-{{ post.modal-id }}" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="close-modal" data-dismiss="modal">
<div class="lr">
<div class="rl">
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2">
<div class="modal-body">
<!-- Project Details Go Here -->
<h2>{{ post.title }}</h2>
<p class="item-intro text-muted"> {{ post.subheading }} </p>
<p>{{ post.description }}</p>
<img class="img-responsive" src="img/portfolio/{{ post.img }}">
<ul class="list-inline">
<li>Date: July 2014</li>
<li>Location: {{ post.location }} </li>
<li>Category: {{ post.category }} </li>
</ul>
<button type="button" class="btn btn-primary" data-dismiss="modal"><i class="fa fa-times"></i> Close Project</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endfor %}
这是我的模态的封面post
---
layout: post
modal-id: 1
title: Post title
date: 2017-01-06
location: Project location
img: img.jpg
category: Post category
alt: image-alt
description: Post description
---
因此,我不确定如何为每个 post 添加多张图片。非常感谢任何帮助!
构建 sequence/array/list 图像和 alt 标签以替换 Front Matter 中的 img:
和 alt:
,然后遍历它们。没有别的了。
示例序列:
images-array:
- image: image-1.jpg
alt: This is some alt text
- image: image-2.jpg
alt: This is some alt text
- image: image-3.jpg
alt: This is some alt text
更新前题:
---
layout: post
modal-id: 1
title: Post title
date: 2017-01-06T00:00:00.000Z
location: Project location
category: Post category
description: Post description
images-array:
- image: image-1.jpg
alt: This is some alt text
- image: image-2.jpg
alt: This is some alt text
- image: image-3.jpg
alt: This is some alt text
---
For循环:
{% for item in post.images-array %}
<img class="img-responsive" src="img/portfolio/{{ item.image }}" alt="{{ item.alt }}">
{% endfor %}
For 循环使用 Bootstrap 列:
{% for post in site.posts %}
<div class="portfolio-modal modal fade" id="portfolioModal-{{ post.modal-id }}" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="close-modal" data-dismiss="modal">
<div class="lr">
<div class="rl"></div>
</div>
</div>
<div class="modal-body">
<h2>{{ post.title }}</h2>
<p class="item-intro text-muted"> {{ post.subheading }} </p>
<p>{{ post.description }}</p>
{% for item in post.images-array %}
<div class="col-sm-4">
<img class="img-responsive" src="img/portfolio/{{ item.image }}" alt="{{ item.alt }}">
</div>
{% endfor %}
<ul class="list-inline">
<li>Date: July 2014</li>
<li>Location: {{ post.location }} </li>
<li>Category: {{ post.category }} </li>
</ul>
<button type="button" class="btn btn-primary" data-dismiss="modal"><i class="fa fa-times"></i> Close Project</button>
</div>
</div>
</div>
</div>
{% endfor %}