Skip to content

Commit

Permalink
Update 'news-homepage/'
Browse files Browse the repository at this point in the history
- counter for ".cards" now uses CSS to automatically number them, instead of manually on HTML.
  • Loading branch information
alpe12 committed Oct 29, 2023
1 parent aef91b9 commit 0ea0758
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
12 changes: 12 additions & 0 deletions news-homepage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,16 @@ padding:
);
```

Learned how to add a counter with css.

```css
main .cards article {
counter-increment: cardscount 1;
}

main .cards article .content .count::before {
content: counter(cardscount, decimal-leading-zero);
}
```

Also learned more about how to use grid. Still a lot to learn though.
6 changes: 3 additions & 3 deletions news-homepage/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,23 @@ <h3><a href="">Is VC Funding Drying Up?</a></h3>
<article>
<img src="./src/images/image-retro-pcs.jpg" alt="">
<div class="content">
<span class="count">01</span>
<span class="count"></span>
<h4><a href="">Reviving Retro PCs</a></h4>
<p>What happens when old PCs are given modern upgrades?</p>
</div>
</article>
<article>
<img src="./src/images/image-top-laptops.jpg" alt="">
<div class="content">
<span class="count">02</span>
<span class="count"></span>
<h4><a href="">Top 10 Laptops of 2022</a></h4>
<p>Our best picks for various needs and budgets.</p>
</div>
</article>
<article>
<img src="./src/images/image-gaming-growth.jpg" alt="">
<div class="content">
<span class="count">03</span>
<span class="count"></span>
<h4><a href="">The Growth of Gaming</a></h4>
<p>How the pandemic has sparked fresh opportunities.</p>
</div>
Expand Down
5 changes: 3 additions & 2 deletions news-homepage/src/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ main .cards {
main .cards article {
display: flex;
gap: 1.5rem;
counter-increment: cardscount 1;
}


main .cards article img {
max-height: 127px;
}
Expand All @@ -207,7 +207,8 @@ main .cards article .content {
justify-content: space-between;
}

main .cards article .content .count {
main .cards article .content .count::before {
content: counter(cardscount, decimal-leading-zero);
font-size: 2rem;
color: var(--grayish-blue);
font-weight: 800;
Expand Down

0 comments on commit 0ea0758

Please sign in to comment.