Skip to content

New Card component #609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Card Show/Card show.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions Card Show/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Product Card with Focus</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="card" tabindex="0">
<img src="https://images.pexels.com/photos/1955134/pexels-photo-1955134.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1" alt="Product Image" class="card-image">
<div class="card-content">
<h2 class="card-title">Product Name</h2>
<p class="card-description">This is a brief description of the product. It highlights key features and benefits.</p>
<button class="card-button">Buy Now</button>
</div>
</div>
</body>
</html>
109 changes: 109 additions & 0 deletions Card Show/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f0f0f0;
transition: background-color 0.3s ease;
}

.card {
background-color: white;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
overflow: hidden;
width: 300px;
transition: all 0.3s ease;
position: relative;
z-index: 1;
padding: 15px;
}

.card:hover, .card:focus-within {
transform: translateY(-5px) scale(1.03);
box-shadow: 0 8px 12px rgba(0, 0, 0, 0.15);
outline: none;
}

.card:focus-within ~ .focus-overlay {
opacity: 1;
visibility: visible;
}

.card-image {
width: 100%;
height: 200px;
object-fit: cover;
}

.card-content {
padding: 20px;
}

.card-title {
font-size: 1.5rem;
font-weight: bold;
margin: 0 0 10px 0;
}

.card-description {
color: #666;
font-size: 0.9rem;
line-height: 1.4;
margin-bottom: 20px;
}

.card-button {
background-color: #007bff;
border: none;
border-radius: 4px;
color: white;
cursor: pointer;
font-size: 1rem;
padding: 10px 20px;
transition: background-color 0.3s ease;
}

.card-button:hover, .card-button:focus {
background-color: #0056b3;
outline: none;
}

.card-button:focus {
box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.5);
}

.focus-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
opacity: 0;
visibility: hidden;
transition: opacity 0.3s ease, visibility 0.3s ease;
z-index: 0;
}

body::after {
content: '';
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(247, 0, 0, 0.5);
opacity: 0;
visibility: hidden;
transition: opacity 0.3s ease, visibility 0.3s ease;
z-index: 0;
pointer-events: none;
}

body:focus-within::after {
opacity: 1;
visibility: visible;
}
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,15 @@ Please be aware that the demos may exhibit significant accessibility issues, suc
**[⬆ back to top](#quick-links)**

---

## <a id="Card-show"></a>Card SHow

[<img src="images/card-shw.gif" height="230" title="Card show">] (https://codepen.io/Sp39/pen/gOEdpeq)

**[⬆ back to top](#quick-links)**

---

## Contributors

Thanks to these wonderful people who have contributed to this project!
Expand Down
9 changes: 5 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ <h1><a href="https://github.com/you-dont-need/You-Dont-Need-JavaScript">You Dont
<a href="./Slideshow/purnasth/index.html">Slideshow</a>
<a href="./Css Tables/index.html">CSS Tables</a>
<a href="./CSS Toggle/index.html">CSS Toggle</a>
<a href="./Card Show/index.html">Card-Show</a>
<a href="./flex Property/new.html">Flex Property</a>
<a href="./grid/abc.html">Grid</a>
<a href="./infinitecarousel/infinite.html">Infinite Carousel</a>
Expand Down Expand Up @@ -485,19 +486,19 @@ <h1><a href="https://github.com/you-dont-need/You-Dont-Need-JavaScript">You Dont
<script>
const darkModeToggle = document.getElementById("dark-mode");
const body = document.body;

if (localStorage.getItem('darkMode') === 'enabled') {
body.classList.replace("light-mode", "dark-mode");
darkModeToggle.checked = true;
}

darkModeToggle.addEventListener("change", () => {
if (darkModeToggle.checked) {
body.classList.replace("light-mode", "dark-mode");
localStorage.setItem('darkMode', 'enabled');
localStorage.setItem('darkMode', 'enabled');
} else {
body.classList.replace("dark-mode", "light-mode");
localStorage.setItem('darkMode', 'disabled');
localStorage.setItem('darkMode', 'disabled');
}
});
</script>
Expand Down