對,他有兩種版型:D
不知道為何大標都想加驚嘆號XD
因為文章資料的內容太常用到了,所以把他整理成了 json 方便之後快速使用~
import React from "react";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faChevronRight } from "@fortawesome/free-solid-svg-icons";
export default function Article() {
const articleData = {
category: "ENTERTAINMENT",
title: " 寶藏男孩持修:「對我來說男子氣概無關外表,而是要負責任。」",
writer: "NICOLE LEE",
dateTime: "2021年6月7日",
img: "https://media.vogue.com.tw/photos/60b9a4fcf37df9e2f39b0216/2:3/w_2880%2cc_limit/29711-1_V.jpg",
};
return (
<div>
{/* ... */}
<div className="post">
<h2 className="post-headline">fashion</h2>
<div className="post-section">
<div className="left-side">
<img src={articleData.img} alt="img" />
<div className="overlay-content">
{articleData.category}
<div className="post-title">{articleData.title}</div>
<hr className="white-hr" />
BY {articleData.writer}
{articleData.dateTime}
</div>
</div>
<div className="right-side">
</div>
</div>
</div>
</div>
);
}
.post
&-section
display: flex
justify-content: space-between
gap: 2.4vw
.left-side
width: (100vw-10vw)/2
justify-content: center
height: 100vh
overflow: hidden
.overlay-content
color: $primary-background-color
position: relative
bottom: 410px
left: 0
padding: 20px 24px 40px
font-weight: bold
.right-side
一樣先排版好~
export default function Article() {
return (
<div>
<div className="post">
<h2 className="post-headline">fashion</h2>
<div className="post-section">
<div className="left-side">
{/* ... */}
</div>
<div className="right-side">
<div className="row">
<div className="post-column">
<div className="square-img">
<img alt="post-img" src={articleData.img} />
</div>
<div className="post-paper">
{articleData.category}
<div className="post-subtitle">{articleData.title}</div>
<hr className="brown-hr" />
BY {articleData.writer}
{articleData.dateTime}
</div>
</div>
<div className="post-column">
<div className="rectangle-img">
<img alt="post-img" src={articleData.img} />
</div>
<div className="post-paper">
{articleData.category}
<div className="post-subtitle">{articleData.title}</div>
<hr className="brown-hr" />
BY {articleData.writer}
{articleData.dateTime}
</div>
</div>
<div className="post-column">
<div className="square-img">
<img alt="post-img" src={articleData.img} />
</div>
<div className="post-paper">
{articleData.category}
<div className="post-subtitle">{articleData.title}</div>
<hr className="brown-hr" />
BY {articleData.writer}
{articleData.dateTime}
</div>
</div>
<div className="post-column">
<div className="rectangle-img">
<img alt="post-img" src={articleData.img} />
</div>
<div className="post-paper">
{articleData.category}
<div className="post-subtitle">{articleData.title}</div>
<hr className="brown-hr" />
BY {articleData.writer}
{articleData.dateTime}
</div>
</div>
</div>
<div className="row">
<div className="post-column">
<div className="rectangle-img">
<img alt="post-img" src={articleData.img} />
</div>
<div className="post-paper">
{articleData.category}
<div className="post-subtitle">{articleData.title}</div>
<hr className="brown-hr" />
BY {articleData.writer}
{articleData.dateTime}
</div>
</div>
<div className="post-column">
<div className="square-img">
<img alt="post-img" src={articleData.img} />
</div>
<div className="post-paper">
{articleData.category}
<div className="post-subtitle">{articleData.title}</div>
<hr className="brown-hr" />
BY {articleData.writer}
{articleData.dateTime}
</div>
</div>
<div className="post-column">
<div className="rectangle-img">
<img alt="post-img" src={articleData.img} />
</div>
<div className="post-paper">
{articleData.category}
<div className="post-subtitle">{articleData.title}</div>
<hr className="brown-hr" />
BY {articleData.writer}
{articleData.dateTime}
</div>
</div>
<div className="post-column">
<div className="square-img">
<img alt="post-img" src={articleData.img} />
</div>
<div className="post-paper">
{articleData.category}
<div className="post-subtitle">{articleData.title}</div>
<hr className="brown-hr" />
BY {articleData.writer}
{articleData.dateTime}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
);
}
這邊在 right-side 下,我使用了兩個 row 的 class 來包裹 column 中的內容,因為後續的 flex box 相關設定無法直接透過 flex box 的屬性讓內容 waterfall 樣式排版(有長有短)
.post
&-section
display: flex
justify-content: space-between
gap: 2.4vw
.left-side
// ...
.right-side
width: (100vw-10vw)/2
height: 100vh
display: flex
overflow: scroll
gap: 2.4vw
overflow-x: hidden
scrollbar-width: none
.row
flex: 1
width: (100vw-60vw)/2
如此一來滾動式卷軸的樣式頁面也完成啦~
感謝大家收看明天見~~~
除此之外,也歡迎大家走走逛逛關於我們團隊夥伴的文章
juck30808 - Python - 數位行銷分析與 Youtube API 教學
SiQing47 - 前端?後端?你早晚都要全端的,何不從現在開始?