


How to achieve adaptive height layout with 2:5:3 scale using CSS Flexbox?
Easily build adaptive and highly layouts with 2:5:3 scale with CSS Flexbox
This article describes how to use the CSS elastic box model (Flexbox) to create a container with the precise height proportion of the three child elements inside it being 2:5:3, and can be automatically adjusted according to the screen size, always maintaining the proportion and filling the parent container height.
We need a container containing three child elements, and the height ratio of these three child elements must be maintained at 2:5:3, and can be perfectly adapted at various screen resolutions. Flexbox layouts can easily achieve this.
The key is to set display: flex
and flex-direction: column
properties of the parent container, which makes the child elements arranged vertically. Then, use the flex
attribute to set the proportion of space occupied by each child element: flex: 2
, flex: 5
, and flex: 3
respectively representing the child element occupying 2 parts, 5 parts and 3 parts of the height of the parent container. The parent container height is automatically adjusted according to the content to ensure that the child elements are proportional correctly and adaptive. For vertical centering, we used align-items: center
.
The following code snippet demonstrates the implementation:
.container { display: flex; flex-direction: column; align-items: center; /* vertical center*/ height: 100vh; /* It occupies full viewport height, can be modified according to actual conditions*/ } .item1 { flex: 2; } .item2 { flex: 5; } .item3 { flex: 3; }
To show the effect more intuitively, we provide a complete HTML example:
<meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Flexbox Layout</title> <style> .container { height: 100vh; width: 100px; background: #000; display: flex; flex-direction: column; align-items: center; } .item1 { flex: 2; background: pink; } .item2 { flex: 5; background-color: blue; } .item3 { flex: 3; background-color: cadetblue; } </style> <div class="container"> <div class="item1"></div> <div class="item2"></div> <div class="item3"></div> </div>
This code creates a highly adaptive layout with a ratio of 2:5:3. The parent container height is set to 100vh
so that it occupies the viewport height, which you can adjust according to actual needs.
The above is the detailed content of How to achieve adaptive height layout with 2:5:3 scale using CSS Flexbox?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

HTML, CSS and JavaScript are the core technologies for building modern web pages: 1. HTML defines the web page structure, 2. CSS is responsible for the appearance of the web page, 3. JavaScript provides web page dynamics and interactivity, and they work together to create a website with a good user experience.

The ranking of virtual currencies’ “oldest” is as follows: 1. Bitcoin (BTC), issued on January 3, 2009, is the first decentralized digital currency. 2. Litecoin (LTC), released on October 7, 2011, is known as the "lightweight version of Bitcoin". 3. Ripple (XRP), issued in 2011, is designed for cross-border payments. 4. Dogecoin (DOGE), issued on December 6, 2013, is a "meme coin" based on the Litecoin code. 5. Ethereum (ETH), released on July 30, 2015, is the first platform to support smart contracts. 6. Tether (USDT), issued in 2014, is the first stablecoin to be anchored to the US dollar 1:1. 7. ADA,

Exchanges that support cross-chain transactions: 1. Binance, 2. Uniswap, 3. SushiSwap, 4. Curve Finance, 5. Thorchain, 6. 1inch Exchange, 7. DLN Trade, these platforms support multi-chain asset transactions through various technologies.

Cryptocurrency data platforms suitable for beginners include CoinMarketCap and non-small trumpet. 1. CoinMarketCap provides global real-time price, market value, and trading volume rankings for novice and basic analysis needs. 2. The non-small quotation provides a Chinese-friendly interface, suitable for Chinese users to quickly screen low-risk potential projects.

The platforms that have outstanding performance in leveraged trading, security and user experience in 2025 are: 1. OKX, suitable for high-frequency traders, providing up to 100 times leverage; 2. Binance, suitable for multi-currency traders around the world, providing 125 times high leverage; 3. Gate.io, suitable for professional derivatives players, providing 100 times leverage; 4. Bitget, suitable for novices and social traders, providing up to 100 times leverage; 5. Kraken, suitable for steady investors, providing 5 times leverage; 6. Bybit, suitable for altcoin explorers, providing 20 times leverage; 7. KuCoin, suitable for low-cost traders, providing 10 times leverage; 8. Bitfinex, suitable for senior play

Suggestions for choosing a cryptocurrency exchange: 1. For liquidity requirements, priority is Binance, Gate.io or OKX, because of its order depth and strong volatility resistance. 2. Compliance and security, Coinbase, Kraken and Gemini have strict regulatory endorsement. 3. Innovative functions, KuCoin's soft staking and Bybit's derivative design are suitable for advanced users.

The detailed introduction of OKX Exchange is as follows: 1) Development history: Founded in 2017 and renamed OKX in 2022; 2) Headquartered in Seychelles; 3) Business scope covers a variety of trading products and supports more than 350 cryptocurrencies; 4) Users are spread across more than 200 countries, with tens of millions of users; 5) Multiple security measures are adopted to protect user assets; 6) Transaction fees are based on the market maker model, and the fee rate decreases with the increase in trading volume; 7) It has won many honors, such as "Cryptocurrency Exchange of the Year".

Institutional investors should choose compliant platforms such as Coinbase Pro and Genesis Trading, focusing on cold storage ratios and audit transparency; retail investors should choose large platforms such as Binance and Huobi, focusing on user experience and security; users in compliance-sensitive areas can conduct fiat currency trading through Circle Trade and Huobi Global, and mainland Chinese users need to go through compliant over-the-counter channels.
