Skip to content

Instantly share code, notes, and snippets.

@Olanetsoft
Created May 26, 2025 14:42
Show Gist options
  • Save Olanetsoft/b29ac63ec7f32b4acf0aa94ff01a0367 to your computer and use it in GitHub Desktop.
Save Olanetsoft/b29ac63ec7f32b4acf0aa94ff01a0367 to your computer and use it in GitHub Desktop.
Cloudinary Lazy Load - styles.css
/* css/styles.css - Method 2: Intersection Observer */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: system-ui, -apple-system, sans-serif;
line-height: 1.6;
color: #333;
}
header {
text-align: center;
padding: 2rem;
background: #f8f9fa;
}
header h1 {
color: #333;
margin-bottom: 0.5rem;
}
/* Hero section - loads immediately */
.hero {
height: 80vh;
position: relative;
overflow: hidden;
background: #000;
}
.hero-video {
width: 100%;
height: 100%;
object-fit: cover;
}
.hero-content {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
color: white;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
}
.hero-content h2 {
font-size: 3rem;
margin-bottom: 1rem;
}
.hero-content p {
font-size: 1.5rem;
}
/* Spacer to demonstrate lazy loading */
.spacer {
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(45deg, #667eea 0%, #764ba2 100%);
color: white;
text-align: center;
font-size: 1.5rem;
}
/* Demo section */
.demo-section {
padding: 4rem 2rem;
max-width: 800px;
margin: 0 auto;
}
.demo-section h2 {
margin-bottom: 2rem;
color: #333;
text-align: center;
}
/* Status display - unique to Method 2 */
.status-display {
background: #1f2937;
color: white;
padding: 1.5rem;
border-radius: 8px;
margin-bottom: 2rem;
font-family: "Courier New", monospace;
}
.status-item {
display: flex;
justify-content: space-between;
margin-bottom: 0.75rem;
align-items: center;
}
.status-item:last-child {
margin-bottom: 0;
}
.status-item .label {
color: #9ca3af;
font-weight: 600;
}
.status-item .value {
color: #10b981;
font-weight: bold;
min-width: 120px;
text-align: right;
}
/* Dynamic status colors */
.status-item .value.not-loaded {
color: #6b7280;
}
.status-item .value.loading {
color: #f59e0b;
}
.status-item .value.playing {
color: #10b981;
}
.status-item .value.error {
color: #ef4444;
}
/* Video container with aspect ratio */
.video-container {
position: relative;
width: 100%;
padding-bottom: 56.25%; /* 16:9 aspect ratio */
background-color: #000;
border-radius: 8px;
overflow: hidden;
margin-bottom: 2rem;
}
.lazy-video {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
}
/* Code example */
.code-example {
background: #1e1e1e;
color: #f8f8f2;
padding: 1.5rem;
border-radius: 8px;
overflow-x: auto;
margin-bottom: 2rem;
}
.code-example pre {
margin: 0;
font-family: "Courier New", monospace;
line-height: 1.4;
}
/* Method info box */
.method-info {
background: #f8f9fa;
padding: 2rem;
border-radius: 8px;
border-left: 4px solid #8b5cf6;
}
.method-info h3 {
margin-bottom: 1rem;
color: #333;
}
.method-info code {
background: #e9ecef;
padding: 0.2rem 0.4rem;
border-radius: 3px;
font-family: "Courier New", monospace;
}
.pros-cons {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 2rem;
margin-top: 1rem;
}
.pros h3 {
color: #10b981;
margin-bottom: 1rem;
}
.cons h3 {
color: #ef4444;
margin-bottom: 1rem;
}
.pros ul,
.cons ul {
list-style: none;
padding-left: 0;
}
.pros li,
.cons li {
margin-bottom: 0.5rem;
padding-left: 1.5rem;
position: relative;
}
.pros li:before {
content: "✅";
position: absolute;
left: 0;
}
.cons li:before {
content: "❌";
position: absolute;
left: 0;
}
/* Testing instructions */
.testing-box {
background: #e0f2fe;
border: 1px solid #0284c7;
border-radius: 8px;
padding: 1.5rem;
margin: 2rem 0;
}
.testing-box h3 {
color: #0369a1;
margin-bottom: 1rem;
}
.testing-box ol {
margin-left: 1.5rem;
}
.testing-box li {
margin-bottom: 0.75rem;
line-height: 1.5;
}
.testing-box code {
background: #1e293b;
color: #10b981;
padding: 0.2rem 0.4rem;
border-radius: 3px;
font-family: "Courier New", monospace;
font-size: 0.9rem;
}
.testing-box ul {
margin-left: 1.5rem;
}
.testing-box ul li {
margin-bottom: 0.25rem;
}
.testing-box p {
margin-top: 1rem;
font-weight: bold;
color: #0369a1;
}
/* Mobile responsive */
@media (max-width: 768px) {
.hero-content h2 {
font-size: 2rem;
}
.hero-content p {
font-size: 1.2rem;
}
.pros-cons {
grid-template-columns: 1fr;
gap: 1rem;
}
.demo-section {
padding: 2rem 1rem;
}
.spacer {
font-size: 1.2rem;
padding: 1rem;
}
.status-display {
font-size: 0.9rem;
}
.status-item {
flex-direction: column;
align-items: flex-start;
gap: 0.25rem;
}
.status-item .value {
text-align: left;
min-width: auto;
}
}
/* Previous CSS from Methods 1 & 2 stays the same, plus these additions: */
/* Optimization display - shows Cloudinary's real-time optimizations */
.optimization-display {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 1.5rem;
border-radius: 8px;
margin-bottom: 2rem;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 1rem;
font-family: "Courier New", monospace;
}
.status-item {
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.status-item .label {
color: rgba(255, 255, 255, 0.8);
font-size: 0.8rem;
font-weight: 600;
text-transform: uppercase;
}
.status-item .value {
color: #ffffff;
font-weight: bold;
padding: 0.25rem 0.5rem;
background: rgba(255, 255, 255, 0.1);
border-radius: 4px;
text-align: center;
}
/* Transformation URL display */
.transformation-display {
background: #1f2937;
padding: 1rem;
border-radius: 8px;
margin-bottom: 2rem;
}
.transformation-display h4 {
color: #f9fafb;
margin-bottom: 0.5rem;
font-size: 0.9rem;
}
.url-display {
background: #111827;
color: #10b981;
padding: 0.75rem;
border-radius: 4px;
font-family: "Courier New", monospace;
font-size: 0.8rem;
word-break: break-all;
line-height: 1.4;
}
/* Method comparison */
.comparison-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1.5rem;
margin-top: 1rem;
}
.comparison-item {
padding: 1rem;
border-radius: 6px;
border: 2px solid #e5e7eb;
}
.comparison-item.better {
border-color: #10b981;
background: #f0fdf4;
}
.comparison-item h4 {
margin-bottom: 0.75rem;
color: #333;
}
.comparison-item ul {
list-style: none;
padding: 0;
}
.comparison-item li {
margin-bottom: 0.5rem;
padding-left: 1.5rem;
position: relative;
}
.comparison-item li:before {
position: absolute;
left: 0;
}
.comparison-item:not(.better) li:before {
content: "❌";
}
.comparison-item.better li:before {
content: "✅";
}
@media (max-width: 768px) {
.optimization-display {
grid-template-columns: 1fr;
}
.comparison-grid {
grid-template-columns: 1fr;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment