Skip to content

Commit

Permalink
sticky card styling update
Browse files Browse the repository at this point in the history
  • Loading branch information
aman-maharshi committed May 23, 2024
1 parent f94ac1b commit caf7524
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
2 changes: 1 addition & 1 deletion parallax-cards/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function App() {
const [data, setData] = useState(cardsData)

return (
<div>
<div className="main">
{data.map((item, index) => {
return (
<Card key={index} item={item} />
Expand Down
7 changes: 4 additions & 3 deletions parallax-cards/src/Card.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ function Card({ item }) {

const {title, description, src, link, color} = item
return (
<div>
<h2>{title}</h2>
<p>{description}</p>
<div className='card-container'>
<div className="card" style={{background: color}}>

</div>
</div>
)
}
Expand Down
28 changes: 27 additions & 1 deletion parallax-cards/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,31 @@
body {
margin: 0;
font-family: "Noto Sans", sans-serif;

}

.main {
margin-top: 50vh;
margin-bottom: 100vh;
}


.card-container {
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
position: sticky;
top: 0;
}

.card {
height: 400px;
width: 800px;
border-radius: 25px;
}

@media (max-width: 1024px) {
.card {
width: 600px;
}
}

0 comments on commit caf7524

Please sign in to comment.