


How Can I Evenly Distribute Inline-Block Elements with `text-align: justify`?
Can ""text-align: justify;"" Inline-Block Elements Spread Out Evenly?
Problem:
Inline-block elements with text-align: justify struggle to distribute content evenly, leaving an empty vertical space at the bottom of the line. Traditional solutions involve using line-height: 0; on the parent element, which can disrupt existing line-height values.
Workaround for Present Browsers (IE8 , FF, Chrome):
This CSS method solves the problem without disrupting line-heights:
.prevNext { text-align: justify; } .prevNext a { display: inline-block; position: relative; top: 1.2em; /* Your line-height */ } .prevNext:before{ content: ''; display: block; width: 100%; margin-bottom: -1.2em; /* Your line-height */ } .prevNext:after { content: ''; display: inline-block; width: 100%; }
The :before element pulls text lines up one line-height, eliminating the extra line but displacing text. Positioning inline-block elements relative counteracts this displacement without adding an extra line.
Future Solution with "-text-align-last: justify;" (Nearing Support):
A cleaner future solution uses:
.prevNext { text-align: justify; text-align-last: justify; /* Supported in IE and FF, experimental in Chrome */ }
In-Progress Webkit Support:
Webkit browsers partially support this solution but require enabling experimental features. Full support is expected in upcoming versions.
The above is the detailed content of How Can I Evenly Distribute Inline-Block Elements with `text-align: justify`?. 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

AI Hentai Generator
Generate AI Hentai for free.

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

Create a JavaScript Contact Form With the Smart Forms Framework

Adding Box Shadows to WordPress Blocks and Elements

Demystifying Screen Readers: Accessible Forms & Best Practices

Create an Inline Text Editor With the contentEditable Attribute

Making Your First Custom Svelte Transition

Comparing the 5 Best PHP Form Builders (And 3 Free Scripts)

File Upload With Multer in Node.js and Express
