我在 HTML 和 CSS 中遇到了困难 table
I'm having a hard times table in HTML & CSS
我正在尝试在此项目中使用 justify-content: space-between,但没有任何改变 IDK 的原因。我试了很多方法,几天后,我一个人试完了,谁能帮帮我?
如果你能帮助我,我将不胜感激
我的项目:
https://github.com/Renan-Olovics/NLW_04-MoveIt
这是错误的方式,就像我一样。
应该是这样的(右边的蓝色)
HTML:
import Head from 'next/head'
import SideBar from '../components/SideBar/Index'
import { LeaderboardApi } from '../services/leaderboardApi'
import styles from '../styles/leaderboard.module.scss'
interface usersProps {
id: string
git: string
name: string
level: number
challenges: number
experience: number
}
interface leaderboardProps {
leaderboardList: Array<usersProps>
}
export default function Leaderboard(props: leaderboardProps) {
return (
<div className={styles.leaderboardPage}>
<Head>
<title>Início | Leaderboard</title>
</Head>
<SideBar />
<div className={styles.container}>
<h1>Leaderboard</h1>
<table>
<thead>
<tr>
<th>POSIÇÃO</th>
<th>
<section>
<p>USUÁRIO</p> <p>EXPERIÊNCIA</p>
</section>
</th>
</tr>
</thead>
<tbody>
{props.leaderboardList.map((data) => {
return (
<tr key={data.id}>
<th>
<h3>1</h3>
</th>
<th className={styles.userInfo}>
<img
src={`http://www.github.com/${data.git}.png`}
alt={data.name}
width={64}
height={64}
/>
<div className={styles.batata}>
<section>
<h3>{data.name}</h3>
<p>
<img src="/icons/level.svg" alt="levelIcon" />
{` Level ${data.level}`}
</p>
</section>
<section>
<p>{data.challenges}</p>
<p className={styles.blueText}>completados</p>
<p>{data.experience}</p>
<p className={styles.blueText}>xp</p>
</section>
</div>
</th>
</tr>
)
})}
</tbody>
</table>
</div>
</div>
)
}
export async function getStaticProps() {
const { data } = await LeaderboardApi.get('users', {
params: {
_limit: 10,
_sort: 'level',
_order: 'desc',
},
})
const leaderboardList = data.map((leaderboard) => {
return {
id: leaderboard.id,
git: leaderboard.git,
name: leaderboard.name,
level: leaderboard.level,
challenges: leaderboard.challenges,
experience: leaderboard.experience,
}
})
return {
props: {
leaderboardList,
},
revalidate: 60 * 10, // 10min
}
}
CSS:
.leaderboardPage {
display: flex;
background-color: var(--background);
}
.container {
width: 100%;
display: flex;
justify-content: center;
flex-direction: column;
margin: 0 20rem 0 20rem;
h1 {
padding: 3rem;
}
thead {
th {
text-transform: uppercase;
color: #666666;
padding-bottom: 1rem;
}
th:last-child {
section {
display: flex;
justify-content: space-between;
p {
padding: 0 5rem 0 5rem;
}
}
}
}
tbody {
th {
align-items: center;
height: 7rem;
}
th:last-child {
width: 100%;
}
img {
border-radius: 50%;
}
tr {
background: orange;
}
}
.blueText {
color: var(--blue);
}
}
.userInfo {
display: flex;
margin-left: 1rem;
background: green;
div {
display: flex;
section:first-child {
display: flex;
flex-direction: column;
background: yellow;
align-self: flex-start;
}
section:last-child {
display: flex;
background: blue;
align-self: center;
justify-content: space-between;
}
}
}
.batata {
display: flex;
}
这将是useful.Please试试这个。
To .batata, add width: 100%; and justify-content: space-between;
我正在尝试在此项目中使用 justify-content: space-between,但没有任何改变 IDK 的原因。我试了很多方法,几天后,我一个人试完了,谁能帮帮我? 如果你能帮助我,我将不胜感激
我的项目: https://github.com/Renan-Olovics/NLW_04-MoveIt
这是错误的方式,就像我一样。
应该是这样的(右边的蓝色)
HTML:
import Head from 'next/head'
import SideBar from '../components/SideBar/Index'
import { LeaderboardApi } from '../services/leaderboardApi'
import styles from '../styles/leaderboard.module.scss'
interface usersProps {
id: string
git: string
name: string
level: number
challenges: number
experience: number
}
interface leaderboardProps {
leaderboardList: Array<usersProps>
}
export default function Leaderboard(props: leaderboardProps) {
return (
<div className={styles.leaderboardPage}>
<Head>
<title>Início | Leaderboard</title>
</Head>
<SideBar />
<div className={styles.container}>
<h1>Leaderboard</h1>
<table>
<thead>
<tr>
<th>POSIÇÃO</th>
<th>
<section>
<p>USUÁRIO</p> <p>EXPERIÊNCIA</p>
</section>
</th>
</tr>
</thead>
<tbody>
{props.leaderboardList.map((data) => {
return (
<tr key={data.id}>
<th>
<h3>1</h3>
</th>
<th className={styles.userInfo}>
<img
src={`http://www.github.com/${data.git}.png`}
alt={data.name}
width={64}
height={64}
/>
<div className={styles.batata}>
<section>
<h3>{data.name}</h3>
<p>
<img src="/icons/level.svg" alt="levelIcon" />
{` Level ${data.level}`}
</p>
</section>
<section>
<p>{data.challenges}</p>
<p className={styles.blueText}>completados</p>
<p>{data.experience}</p>
<p className={styles.blueText}>xp</p>
</section>
</div>
</th>
</tr>
)
})}
</tbody>
</table>
</div>
</div>
)
}
export async function getStaticProps() {
const { data } = await LeaderboardApi.get('users', {
params: {
_limit: 10,
_sort: 'level',
_order: 'desc',
},
})
const leaderboardList = data.map((leaderboard) => {
return {
id: leaderboard.id,
git: leaderboard.git,
name: leaderboard.name,
level: leaderboard.level,
challenges: leaderboard.challenges,
experience: leaderboard.experience,
}
})
return {
props: {
leaderboardList,
},
revalidate: 60 * 10, // 10min
}
}
CSS:
.leaderboardPage {
display: flex;
background-color: var(--background);
}
.container {
width: 100%;
display: flex;
justify-content: center;
flex-direction: column;
margin: 0 20rem 0 20rem;
h1 {
padding: 3rem;
}
thead {
th {
text-transform: uppercase;
color: #666666;
padding-bottom: 1rem;
}
th:last-child {
section {
display: flex;
justify-content: space-between;
p {
padding: 0 5rem 0 5rem;
}
}
}
}
tbody {
th {
align-items: center;
height: 7rem;
}
th:last-child {
width: 100%;
}
img {
border-radius: 50%;
}
tr {
background: orange;
}
}
.blueText {
color: var(--blue);
}
}
.userInfo {
display: flex;
margin-left: 1rem;
background: green;
div {
display: flex;
section:first-child {
display: flex;
flex-direction: column;
background: yellow;
align-self: flex-start;
}
section:last-child {
display: flex;
background: blue;
align-self: center;
justify-content: space-between;
}
}
}
.batata {
display: flex;
}
这将是useful.Please试试这个。
To .batata, add width: 100%; and justify-content: space-between;