基于.NetCore开发博客项目 StarBlog - (10) 图片瀑布流
系列文章
- 基于.NetCore开发博客项目 StarBlog - (1) 为什么需要自己写一个博客?
- 基于.NetCore开发博客项目 StarBlog - (2) 环境准备和创建项目
- 基于.NetCore开发博客项目 StarBlog - (3) 模型设计
- 基于.NetCore开发博客项目 StarBlog - (4) markdown博客批量导入
- 基于.NetCore开发博客项目 StarBlog - (5) 开始搭建Web项目
- 基于.NetCore开发博客项目 StarBlog - (6) 页面开发之博客文章列表
- 基于.NetCore开发博客项目 StarBlog - (7) 页面开发之文章详情页面
- 基于.NetCore开发博客项目 StarBlog - (8) 分类层级结构展示
- 基于.NetCore开发博客项目 StarBlog - (9) 图片批量导入
- 基于.NetCore开发博客项目 StarBlog - (10) 图片瀑布流
- ...
前言
上一篇介绍了图片批量导入操作,我看到有同学留言问怎么没有上传图片的介绍,这里再解释一下,本系列文章介绍的顺序是:
- 从 博客的网站前台 到 管理后台
- 从 后端C#代码 到 前端Vue+ElementUI
所以上传图片这部分会在后续的管理后台开发中介绍,欢迎继续关注哈~
接着上篇文章,继续介绍摄影模块,图片导入之后,需要做展示,本文介绍(水)图片瀑布流的实现。
PS:涉及到的技术很简单,所以本文会比较水一点,请大佬们跳过吧~
先看效果
导入一些爬虫采集的壁纸作为测试数据,先看看瀑布流效果

管理后台的瀑布流

这是首页卡片效果

实现
瀑布流原理很简单,有一堆现成的轮子可以用,那就不造轮子了(直接CV操作)哈哈哈
博客前台的这个瀑布流我选的是masonry-layout,项目主页:https://github.com/desandro/masonry
选这个组件的原因是我看到Bootstrap5的例子代码里用了这个实现瀑布流,那我就copy过来了(逃
使用方法很简单
<div class="row" data-masonry='{"percentPosition": true }'>
@foreach (var photo in Model.Photos) {
<div class="col-sm-6 col-lg-4 mb-4">
<partial name="Widgets/PhotoCard" model="photo"/>
</div>
}
</div>
有很多option可以配置,我没深入研究
它的github主页也没怎么介绍,文档都在官网里:https://masonry.desandro.com/
这个官网的风格也是别具一格(逃
管理后台的瀑布流是用vue-waterfall组件实现的,具体在后续的文章里会介绍~
最后首页这几个卡片也是我在Bootstrap5的例子里参考魔改来的
代码如下
@model Photo
<div class="card card-cover h-100 overflow-hidden text-white bg-dark rounded-5 shadow-lg"
style="background-image: url('media/@Model.FilePath.Replace("\\", "/")');">
<div class="d-flex flex-column h-100 p-5 pb-3 text-white text-shadow-1">
<h2 class="pt-5 mt-5 mb-5 display-6 lh-1 fw-bold">
@Model.Title
<p></p>
</h2>
<ul class="d-flex list-unstyled mt-auto">
<li class="me-auto">
<img src="~/images/star.jpg" alt="Bootstrap" width="32" height="32" class="rounded-circle border border-white">
</li>
<li class="d-flex align-items-center me-3">
<span class="bi me-2">
<i class="fa-solid fa-location-pin"></i>
</span>
<small>@Model.Location</small>
</li>
<li class="d-flex align-items-center">
<span class="bi me-2">
<i class="fa-solid fa-calendar-days"></i>
</span>
<small>@Model.CreateTime.ToShortDateString()</small>
</li>
</ul>
</div>
</div>
搞定~
最后
今天刚好是六一儿童节,路上看到很多小朋友都出来玩了,很棒,祝各位大朋友小朋友天天开心~
基于.NetCore开发博客项目 StarBlog - (10) 图片瀑布流的更多相关文章
- 基于.NetCore开发博客项目 StarBlog - (9) 图片批量导入
系列文章 基于.NetCore开发博客项目 StarBlog - (1) 为什么需要自己写一个博客? 基于.NetCore开发博客项目 StarBlog - (2) 环境准备和创建项目 基于.NetC ...
- 基于.NetCore开发博客项目 StarBlog - (11) 实现访问统计
系列文章 基于.NetCore开发博客项目 StarBlog - (1) 为什么需要自己写一个博客? 基于.NetCore开发博客项目 StarBlog - (2) 环境准备和创建项目 基于.NetC ...
- 基于.NetCore开发博客项目 StarBlog - (12) Razor页面动态编译
系列文章 基于.NetCore开发博客项目 StarBlog - (1) 为什么需要自己写一个博客? 基于.NetCore开发博客项目 StarBlog - (2) 环境准备和创建项目 基于.NetC ...
- 基于.NetCore开发博客项目 StarBlog - (13) 加入友情链接功能
系列文章 基于.NetCore开发博客项目 StarBlog - (1) 为什么需要自己写一个博客? 基于.NetCore开发博客项目 StarBlog - (2) 环境准备和创建项目 基于.NetC ...
- 基于.NetCore开发博客项目 StarBlog - (14) 实现主题切换功能
系列文章 基于.NetCore开发博客项目 StarBlog - (1) 为什么需要自己写一个博客? 基于.NetCore开发博客项目 StarBlog - (2) 环境准备和创建项目 基于.NetC ...
- 基于.NetCore开发博客项目 StarBlog - (15) 生成随机尺寸图片
系列文章 基于.NetCore开发博客项目 StarBlog - (1) 为什么需要自己写一个博客? 基于.NetCore开发博客项目 StarBlog - (2) 环境准备和创建项目 基于.NetC ...
- 基于.NetCore开发博客项目 StarBlog - (16) 一些新功能 (监控/统计/配置/初始化)
系列文章 基于.NetCore开发博客项目 StarBlog - (1) 为什么需要自己写一个博客? 基于.NetCore开发博客项目 StarBlog - (2) 环境准备和创建项目 基于.NetC ...
- 基于.NetCore开发博客项目 StarBlog - (17) 自动下载文章里的外部图片
系列文章 基于.NetCore开发博客项目 StarBlog - (1) 为什么需要自己写一个博客? 基于.NetCore开发博客项目 StarBlog - (2) 环境准备和创建项目 基于.NetC ...
- 基于.NetCore开发博客项目 StarBlog - (18) 实现本地Typora文章打包上传
前言 九月太忙,只更新了三篇文章,本来这个功能是从九月初就开始做的,结果一直拖到现在国庆假期才有时间完善并且写文章~ 之前我更新了几篇关于 Python 的文章,有朋友留言问是不是不更新 .Net 了 ...
随机推荐
- JavaScript 小技巧 数组去重
const array = [1, 2, 3, 3, 5, 5, 1]; const uniqueArray = [...new Set(array)]; console.log(uniqueArra ...
- ServletContext介绍和用法总结
ServletContext介绍和用法总结 学习总结 一.ServletContext 介绍 1. 概念 2. 作用 3. 获取 3.1 在实现类中获取 3.2 在 Spring 容器中获取 二.Se ...
- 小程序生成海报demo
效果图: <view class='poste_box' id='canvas-container' style="margin:0 auto;border-radius:16rpx; ...
- 防止自己的页面不被其他网站的页面的iframe引用
方法用二: 一.设置http请求头的X-Frame-Options: X-Frame-Options可以设置三个值 1.DENY 代表页面不会能被嵌入到iframe或者frame里 2.SAMEOR ...
- lunix或者centos服务器下如何下载自己在github上面的项目代码
1.在github找到项目压缩包下载地址 打开自己的github主页找到需要下载的项目首页,如图所示,找到zip下载地址(ps:如何找这个地址我就不多说了,了解过一点html的同学肯定很容易可以找到) ...
- Wireshark捕获网易云音乐音频文件地址
打开Wireshark,开始捕获. 打开网易云音乐,然后播放一首歌. Wireshark停时捕获,然后在不活的文件中搜索字符串"mp3".可以发现有如下信息: 将其中的内容:&qu ...
- CVE 公开披露的网络安全漏洞列表
CVE®是一份公开披露的网络安全漏洞列表, 官方地址为 : https://cve.mitre.org/cve/ 比如 mavenrepository 上阿里的Druid修复的漏洞的列表如下:
- 1.Java基础
1.注释 单行注释 // 多行注释 /*回车 文档注释(注解)./**回车 2.标识符 (1)Java所有组成部分都需要名字,类名,变量名以及方法名都称为标识符 (2)且标识符只能以字母.$或者_ 开 ...
- 使用Harr特征的级联分类器实现目标检测
前言 最近在学习人脸的目标检测任务时,用了Haar人脸检测算法,这个算法实现起来太简洁了,读入个.xml,调用函数就能用.但是深入了解我发现这个算法原理很复杂,也很优秀.究其根源,于是我找了好些篇相 ...
- android软件简约记账app开发day10-主页面模块--头信息的展示,和之后功能完善的目标。
android软件简约记账app开发day10-主页面模块--头信息的展示,和之后功能完善的目标. 今天来写主界面头信息的展示,也就是将第一天的写的layout中的item_main_top展示到主界 ...