Square-Box Vertical Center - Method 2
How do I make an square-box vertical center - method 2?
In a clients project I needed to center content vertically, without knowing how much content it was. No Javascript.. What is a square-box vertical center - method 2? How do you make a square-box vertical center - method 2? This script and codes were developed by Tom Lutzenberger on 24 August 2022, Wednesday.
Square-Box Vertical Center - Method 2 - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Square-Box Vertical Center - Method 2</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="container"> <div class="row"> <h1 class="col-xs-12 text-center">Vertical centered square boxes</h1> <div class="col-xs-12 alert alert-info text-center"> <p>The class <code>.square-wrap</code> provides the square shape, while the inner classes (<code>.v-center-wrap</code> and <code>.v-center</code>) do the alignment.</p><strong>Always square. Always vertical centered. No matter the size.</strong> </div> <div class="col-xs-1 col-xs-offset-3"> <div class="square-wrap"> <div class="v-center-wrap bg-primary"> <div class="v-center text-center"> <h3>ABC</h3> </div> </div> </div> </div> <div class="col-xs-2"> <div class="square-wrap"> <div class="v-center-wrap bg-primary"> <div class="v-center text-center"> <h3>Product</h3> <p>Some text and data</p> </div> </div> </div> </div> <div class="col-xs-3"> <div class="square-wrap"> <div class="v-center-wrap bg-primary"> <div class="v-center text-center"> <h3>Product</h3> <p>Some text and data</p> </div> </div> </div> </div> </div>
</div>
</body>
</html>
Square-Box Vertical Center - Method 2 - Script Codes CSS Codes
.square-wrap { height: 0; margin-bottom: 30px; overflow: hidden; padding-top: 100%; position: relative;
}
.square-wrap > .v-center-wrap { height: 100%; margin-bottom: 0; margin-top: -100%; position: absolute; width: 100%;
}
.v-center { padding-top: 50%; transform: translate(0, -25%);
}
.v-center > *:first-child { margin-top: 0;
}
.v-center > *:last-child { margin-bottom: 0;
}
Developer | Tom Lutzenberger |
Username | tomlutzenberger |
Uploaded | August 24, 2022 |
Rating | 3 |
Size | 2,701 Kb |
Views | 46,552 |
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 Folders | 2,614 Kb |
Hxgn | 4,203 Kb |
Square-Box Vertical Center | 2,774 Kb |
Palindrome check | 2,177 Kb |
A Pen by Tom Lutzenberger | 2,530 Kb |
Standard Template | 1,454 Kb |
Pseudo ASCII-Art | 10,362 Kb |
Auto-scaling iframes | 3,057 Kb |
Weather widget | 2,486 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 |
Zip Button test | Lje7462 | 1,932 Kb |
Shopping List | Markmurray | 6,015 Kb |
BenU Maintenance Site | Ksherman | 4,893 Kb |
Simple Login Form | JoshBlackwood | 4,418 Kb |
Lightrays v2 | Sinthetyc | 2,903 Kb |
Price | Catcode | 2,623 Kb |
Web Spiral - p5.js | TWAIN | 2,183 Kb |
Cool Page Split Effect | Anthonyadamski | 6,128 Kb |
CSS 3D Radio buttons | Andreasnylin | 1,650 Kb |
Wip elementary os navbar | Nickcolley | 2,993 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!