<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>HTML &#8211; CYFOR&#039;blog</title>
	<atom:link href="https://www.cyfor.cn/tag/html/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.cyfor.cn</link>
	<description>是个人，还活着，争取再活几年</description>
	<lastBuildDate>Thu, 21 Aug 2025 07:24:09 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.5</generator>

<image>
	<url>https://www.cyfor.cn/wp-content/uploads/2020/04/cropped-狗粮-2-150x150.png</url>
	<title>HTML &#8211; CYFOR&#039;blog</title>
	<link>https://www.cyfor.cn</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>修改index.scss给VuePress增加图片左右滑动区块</title>
		<link>https://www.cyfor.cn/%e4%bf%ae%e6%94%b9index-scss%e7%bb%99vuepress%e5%a2%9e%e5%8a%a0%e5%9b%be%e7%89%87%e5%b7%a6%e5%8f%b3%e6%bb%91%e5%8a%a8%e5%8c%ba%e5%9d%97/</link>
					<comments>https://www.cyfor.cn/%e4%bf%ae%e6%94%b9index-scss%e7%bb%99vuepress%e5%a2%9e%e5%8a%a0%e5%9b%be%e7%89%87%e5%b7%a6%e5%8f%b3%e6%bb%91%e5%8a%a8%e5%8c%ba%e5%9d%97/#respond</comments>
		
		<dc:creator><![CDATA[CYFOR]]></dc:creator>
		<pubDate>Tue, 20 May 2025 03:00:22 +0000</pubDate>
				<category><![CDATA[奇怪的技能]]></category>
		<category><![CDATA[追星]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[vuepress]]></category>
		<category><![CDATA[开源]]></category>
		<category><![CDATA[网站]]></category>
		<guid isPermaLink="false">https://www.cyfor.cn/?p=202</guid>

					<description><![CDATA[通过在styles\index.scss添加自定义全局样式CSS，实现VuePress图片左右滑动效果
]]></description>
										<content:encoded><![CDATA[
<p>更新<a href="http://www.jaychou.wiki" target="_blank" rel="noopener">JayChou-Wiki</a>时从各处收集了很多历史图片资源，VuePress的是基于MarkDown文件生成的页面，所以支持md的插入图片语法和html标签。因为用了<a href="https://theme-hope.vuejs.press/zh/" target="_blank" rel="noopener">hope</a>主题，内置了<a href="https://theme-hope.vuejs.press/zh/guide/feature/photo-swipe.html" target="_blank" rel="noopener">图片预览插件</a>，实现了以下交互效果：<br></p>



<p>&#8211; 左右滑动按顺序浏览页面内其他的图片<br>&#8211; 查看图片的描述<br>&#8211; 对图片进行缩放<br>&#8211; 全屏浏览图片<br>&#8211; 下载图片<br>&#8211; 分享图片</p>



<p>但无法实现图片的左右滑动，当单个页面需要引用大量图片时，即便每张图片都单独设置了尺寸，也会显得很杂乱。找了很久解决方案，在hope页面的<a href="https://github.com/vuepress-theme-hope/vuepress-theme-hope/edit/main/docs/theme/src/zh/guide/feature/photo-swipe.md" target="_blank" rel="noopener">源码仓库</a>中发现作者本人是直接写的html平铺效果。</p>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1024" height="500" src="https://www.cyfor.cn/wp-content/uploads/2025/05/image-1024x500.png" alt="github-hope-photo-swipe.md" class="wp-image-203" srcset="https://www.cyfor.cn/wp-content/uploads/2025/05/image-1024x500.png 1024w, https://www.cyfor.cn/wp-content/uploads/2025/05/image-300x147.png 300w, https://www.cyfor.cn/wp-content/uploads/2025/05/image-768x375.png 768w, https://www.cyfor.cn/wp-content/uploads/2025/05/image-1536x751.png 1536w, https://www.cyfor.cn/wp-content/uploads/2025/05/image.png 1911w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">github-hope-photo-swipe.md</figcaption></figure>



<p>但是每个页面都单独写html也太麻烦了，所以使用AiAgent（忘记是阿里通义灵码还是腾讯CodeBuddy了，反正这种小任务都差不多）在<strong>src.vuepress\styles\index.scss</strong>添加了<a href="https://theme-hope.vuejs.press/zh/config/style.html" target="_blank" rel="noopener">自定义全局样式</a>，最终实现效果如下：</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="500" src="https://www.cyfor.cn/wp-content/uploads/2025/05/image-1-1024x500.png" alt="jaychou.wiki自定义vuepress图片左右滑动效果" class="wp-image-204" srcset="https://www.cyfor.cn/wp-content/uploads/2025/05/image-1-1024x500.png 1024w, https://www.cyfor.cn/wp-content/uploads/2025/05/image-1-300x147.png 300w, https://www.cyfor.cn/wp-content/uploads/2025/05/image-1-768x375.png 768w, https://www.cyfor.cn/wp-content/uploads/2025/05/image-1-1536x751.png 1536w, https://www.cyfor.cn/wp-content/uploads/2025/05/image-1.png 1911w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<pre class="wp-block-code"><code><code>// 图片滑动组件样式
.image-scroll-container {
  width: 100%;
  overflow: hidden;
  position: relative;
  margin: 1rem 0;
}

.image-scroll-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1rem 0;
}

.image-scroll-content {
  display: flex;
  gap: 1rem;
  padding: 0 1rem;
  min-width: max-content;
}

.image-scroll-content img {
  height: 200px;
  min-width: 300px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

// 图片说明文本样式
.image-scroll-content figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.image-scroll-content figcaption {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: #666;
  text-align: center;
}

@media (max-width: 768px) {
  .image-scroll-content img {
    height: 150px;
    min-width: 200px;
  }
  
  .image-scroll-content figcaption {
    font-size: 0.8rem;
  }
}</code></code></pre>



<p>使用时直接在页面中添加：</p>



<pre class="wp-block-code"><code>&lt;div class="image-scroll-container">
  &lt;div class="image-scroll-wrapper">
    &lt;div class="image-scroll-content">
        &lt;figure>
            &lt;img src="图片链接" alt="图片标签" />
            &lt;figcaption>图片显示名&lt;/figcaption>
        &lt;/figure>
    &lt;/div>
  &lt;/div>
&lt;/div></code></pre>
]]></content:encoded>
					
					<wfw:commentRss>https://www.cyfor.cn/%e4%bf%ae%e6%94%b9index-scss%e7%bb%99vuepress%e5%a2%9e%e5%8a%a0%e5%9b%be%e7%89%87%e5%b7%a6%e5%8f%b3%e6%bb%91%e5%8a%a8%e5%8c%ba%e5%9d%97/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
