Spacing elements (no collapsing)
How do I make an spacing elements (no collapsing)?
See: http://simurai.com/blog/2014/05/25/spacing-elements/Forked from simurai's Pen Spacing elements (no collapsing).. What is a spacing elements (no collapsing)? How do you make a spacing elements (no collapsing)? This script and codes were developed by James Nowland on 31 October 2022, Monday.
Spacing elements (no collapsing) - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Spacing elements (no collapsing)</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <h1>Equal Spacing without <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/margin_collapsing">margin-collapsing</a></h1>
<h2>First child display:none proof</h2>
<header class="Header"> <div class="Header-item" style="display:none;">Item</div> <div class="Header-item">Item</div> <div class="Header-item">Item</div> <div class="Header-item">Item</div>
</header>
<h2>First child & (sibling * n) display:none proof</h2>
<header class="Header"> <div class="Header-item" style="display:none;">Item</div> <div class="Header-item" style="display:none;">Item</div> <div class="Header-item">Item</div> <div class="Header-item">Item</div>
</header>
<h2>Last child display:none proof</h2>
<header class="Header"> <div class="Header-item">Item</div> <div class="Header-item">Item</div> <div class="Header-item">Item</div> <div class="Header-item" style="display:none;">Item</div>
</header>
<a href="http://simurai.com/blog/2014/05/25/spacing-elements/">See simurai post for more context.</a> <script src="js/index.js"></script>
</body>
</html>
Spacing elements (no collapsing) - Script Codes CSS Codes
/* This method works because we use first child which allows us to go down the dom*/
.Header-item { margin-right: 2rem;
}
.Header-item:first-child { margin-left: 2em;
}
.Header-item:first-child[style*="display:none;"]
~ .Header-item:not([style*="display:none;"]) { margin-left: 2em;
}
.Header-item:first-child[style*="display:none;"]
~ .Header-item:not([style*="display:none;"]) ~ .Header-item { margin-left: initial;
}
.is-hidden { display: none;
}
/* ------------------------------------ */
.Header { display: -webkit-box; display: -ms-flexbox; display: flex; background: #c8d9f9;
}
.Header-item { -webkit-box-flex: 1; -ms-flex: 1; flex: 1; text-align: center; line-height: 3; color: white; background: #6494ed;
}
body { font-size: 18px; font-family: Avenir, sans-serif; text-align: center;
}
Spacing elements (no collapsing) - Script Codes JS Codes
// In reply to this:
// http://simurai.com/blog/2014/05/25/spacing-elements/
Developer | James Nowland |
Username | jnowland |
Uploaded | October 31, 2022 |
Rating | 3 |
Size | 2,772 Kb |
Views | 12,144 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
CSS Ribbon with inner border. | 166,994 Kb |
CSS3 Stroke and Gradient Text | 2,577 Kb |
Download Rebound | 10,865 Kb |
Dribble Button CSS Rebound | 7,557 Kb |
SVG Modified with Query String | 1,663 Kb |
Login Form CSS only validation | 5,739 Kb |
Pure CSS Spinner | 3,909 Kb |
A Pen by James Nowland | 6,998 Kb |
Step 3 | 3,874 Kb |
Lorem pixel Images | 2,290 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
To Do List with Delete | Mattlbrody | 2,068 Kb |
A Pen by aleen42 | Aleen42 | 11,473 Kb |
Border-radius animation | Yukulele | 2,480 Kb |
Fixed with using Calc | Tomleo | 2,542 Kb |
Awesome | Samarthpd | 2,901 Kb |
STAR WARS LIGHTSABER | Francoiscoron | 4,420 Kb |
LAMP PURE CSS with Animation | Dam62500 | 2,911 Kb |
Custom checkbox example | Capelo | 3,495 Kb |
Count up | Alanshortis | 2,391 Kb |
Shopping List | Markmurray | 6,015 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!