How I Learned to Stop
Worrying and Love the
inline-block
by Robert Szaloki
Create a carousel
The carousel
<section>
</section>
List of items
<section>
<ol></ol>
</section>
Navigation
<section>
<ol></ol>
<button>&lang;</button>
<button>&rang;</button>
</section>
The code
<!DOCTYPE html>
<html lang="en-us">
<head>...</head>
<body>
<section data-component="carousel">
<button data-carousel-nav="prev">&lang;</button>
<button data-carousel-nav="next">&rang;</button>
<ol>
<li></li>
<li></li>
<li></li>
…
</ol>
</section>
<hr>
The code
<!DOCTYPE html>
<html lang="en-us">
<head>...</head>
<body>
<section data-component="carousel">
<button data-carousel-nav="prev">&lang;</button>
<button data-carousel-nav="next">&rang;</button>
<ol>
<li></li>
<li></li>
<li></li>
…
</ol>
</section>
<hr>
position:relative
position:absolute;
top:0;
bottom:0;
height:40px;
margin:auto 0;
width:40px;
…
margin:0 40px;
Dimensions
expand
40px 40pxexpand
40pxautoauto
bottom:0;
top:0;
Carousel item
<li>
<strong>....</strong>
<img>
<button>...</button>
<p>...</p>
</li>
Carousel item
<li>
<strong>....</strong>
<img>
<button>...</button>
<p>...</p>
</li> display:block
display:inline;
max-width:100%
float:left;
width:100%
display:inline-block;
vertical-align:baseline;
text-align:center;
white-space:normal;
box-sizing:border-box;
width:25%;
padding:0 10px;
Almost...
<!DOCTYPE html>
<html lang="en-us">
<head>...</head>
<body>
<section data-component="carousel">
<button data-carousel-nav="prev">&lang;</button>
<button data-carousel-nav="next">&rang;</button>
<ol>
<li></li>
<li></li>
<li></li>
…
</ol>
</section>
<hr>
margin:0 40px;
white-space:nowrap;
overflow:hidden;
transition:all 0.3s ease-in-out;
How will it move?
<ol> width
text-indent:-[<ol> width]px
DEMO!
https://c9.io/rszaloki_1/carousel/workspace/index.html
Debug mode
But why?
● the <li> elements are now inline
elements, so they create a line box
Line box? Line of text!
Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Aenean ac gravida sapien. Nullam
tristique congue pharetra. Nullam fringilla pulvinar
ipsum in adipiscing. Donec porttitor justo tortor. Sed
risus ipsum, porta ac dui vitae, faucibus bibendum
purus. Integer congue scelerisque tristique.
Line boxes
<div>
Lorem ipsum dolor sit amet,
<b>consectetur adipiscing elit. Aenean ac</b>
gravida sapien. Nullam tristique congue pharetra.
<i>Nullam fringilla pulvinar ipsum in adipiscing.</i>
Donec porttitor justo tortor. Sed risus ipsum, porta ac dui
vitae, faucibus bibendum purus. Integer congue
scelerisque tristique.
</div>
Height of a line box
inline-block
<img>
Text
the tallest in the line
or the line-height
value
vertical-align:top;
But why?
● the <li> elements are now inline
elements, so they create a line box
● vertical-align:baseline means, the
elements in a line box should align with
the parents baseline
vertical-align
● baseline: align to the parents baseline
● top: top of the line
● middle: Aligns the middle of the element with the
middle of lowercase letters in the parent. (???)
● <value>
● <percentage>
“The baseline of an 'inline-block' is the
baseline of its last line box in the normal
flow”
But why?
● the <li> elements are now inline
elements, so they create a line box
● vertical-align:baseline means, the
elements in a line box should align with
the parents baseline
● since the <p> is not in the rendering flow
(because it’s floating) the current baseline
is the baseline of the button’s text.
● only the inline blocks are in the parent, so
they will align nicely
Uhm, wait!
MIND THE GAP
<ol>n
t <li>...</li>n
t <li>...</li>n
t <li>...</li>n
</ol>
I see white spaces!
MIND THE GAP
white spaces
HTML is data
● you are not programming in HTML
● it’s not a poem, it’s a structured, linked,
semantic data
● don’t add white spaces, just for formatting
● the DOM is your target, not the View
Source
“Uglify”
<ol>
<li>...</li>
<li>...</li>
<li>...</li>
</ol>
<ol>
<li>...
</li><li>...
</li><li>...
</li>
</ol>
Add interaction - Javascript
Let’s see the code!
Add interaction - Javascript
● use event delegation
● use Event.currentTarget and Event.target
● use jQuery, but you don’t need jQuery
plugins
● define behaviours
THANK YOU!
Questions?
http://c9.io/rszaloki_1/carousel
contact: robert.szaloki@euedge.com

More Related Content

PDF
Haml. New HTML? (RU)
PDF
HTML Bootstrap Workshop
PPTX
Haml in 5 minutes
TXT
Pp checker
PPTX
Introduction to HAML
PDF
2016 First steps with Angular 2 – enterjs
PPTX
Class 10
PDF
CSS Frameworks
Haml. New HTML? (RU)
HTML Bootstrap Workshop
Haml in 5 minutes
Pp checker
Introduction to HAML
2016 First steps with Angular 2 – enterjs
Class 10
CSS Frameworks

Viewers also liked (9)

PDF
Google glass a developers perspective
PDF
Advanced python
PDF
Eu edge intro
PDF
What is python
PDF
Pouch db tdc2016
PDF
Synchronization with CouchDB and PouchDB
PDF
How does it work the keyboard
PDF
Res tful services
PDF
Node webkit-meetup
Google glass a developers perspective
Advanced python
Eu edge intro
What is python
Pouch db tdc2016
Synchronization with CouchDB and PouchDB
How does it work the keyboard
Res tful services
Node webkit-meetup
Ad

Similar to How I learned to Stop Worrying and Love the inline-block (20)

PPTX
Untangling7
ODP
HTML 5 Simple Tutorial Part 3
PPTX
Pres
PPTX
Fundamentals of Browser Rendering Css Overview PT 1
PDF
La build your own website september 5
PDF
Sick Cycle Carousel
PPTX
jQuery Mobile
PPTX
html5_basic_frontend_development_hy.pptx.pptx
PDF
Tailwind Carousel: Create Responsive Carousels Easily - Blogs
PDF
Introduction to jQuery Mobile
PDF
Web app-la-jan-2
PPT
Introduction to HTML
PDF
jQuery Loves Developers - Oredev 2009
PDF
Baawjsajq109
PDF
BYOWHC823
PDF
Everything is Awesome - Cutting the Corners off the Web
PDF
Devdays Seattle jQuery Intro for Developers
PPTX
Untangling spring week5
PPTX
Web page development (day1)
PPTX
Web page development (day1)
Untangling7
HTML 5 Simple Tutorial Part 3
Pres
Fundamentals of Browser Rendering Css Overview PT 1
La build your own website september 5
Sick Cycle Carousel
jQuery Mobile
html5_basic_frontend_development_hy.pptx.pptx
Tailwind Carousel: Create Responsive Carousels Easily - Blogs
Introduction to jQuery Mobile
Web app-la-jan-2
Introduction to HTML
jQuery Loves Developers - Oredev 2009
Baawjsajq109
BYOWHC823
Everything is Awesome - Cutting the Corners off the Web
Devdays Seattle jQuery Intro for Developers
Untangling spring week5
Web page development (day1)
Web page development (day1)
Ad

More from EU Edge (8)

PDF
Node.js
PDF
WebGL
PDF
Python alapu mobil backend
PDF
Open gl
PDF
Google glass ict day presentation
PDF
Frontend meetup 2014.06.25
PDF
Halado css eu edge
PDF
Miért jó oktatóanyagot készíteni?
Node.js
WebGL
Python alapu mobil backend
Open gl
Google glass ict day presentation
Frontend meetup 2014.06.25
Halado css eu edge
Miért jó oktatóanyagot készíteni?

Recently uploaded (20)

PDF
Topaz Photo AI Crack New Download (Latest 2025)
PPTX
How to Odoo 19 Installation on Ubuntu - CandidRoot
PDF
Microsoft Office 365 Crack Download Free
PDF
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
PPTX
Python is a high-level, interpreted programming language
PDF
iTop VPN Crack Latest Version Full Key 2025
PDF
Type Class Derivation in Scala 3 - Jose Luis Pintado Barbero
PDF
DNT Brochure 2025 – ISV Solutions @ D365
PPTX
Lecture 5 Software Requirement Engineering
PPTX
Computer Software - Technology and Livelihood Education
PDF
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
PDF
Visual explanation of Dijkstra's Algorithm using Python
PPTX
Airline CRS | Airline CRS Systems | CRS System
PDF
How Tridens DevSecOps Ensures Compliance, Security, and Agility
PPTX
GSA Content Generator Crack (2025 Latest)
PDF
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
PDF
BoxLang Dynamic AWS Lambda - Japan Edition
PDF
Introduction to Ragic - #1 No Code Tool For Digitalizing Your Business Proces...
PPTX
most interesting chapter in the world ppt
DOCX
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx
Topaz Photo AI Crack New Download (Latest 2025)
How to Odoo 19 Installation on Ubuntu - CandidRoot
Microsoft Office 365 Crack Download Free
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
Python is a high-level, interpreted programming language
iTop VPN Crack Latest Version Full Key 2025
Type Class Derivation in Scala 3 - Jose Luis Pintado Barbero
DNT Brochure 2025 – ISV Solutions @ D365
Lecture 5 Software Requirement Engineering
Computer Software - Technology and Livelihood Education
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
Visual explanation of Dijkstra's Algorithm using Python
Airline CRS | Airline CRS Systems | CRS System
How Tridens DevSecOps Ensures Compliance, Security, and Agility
GSA Content Generator Crack (2025 Latest)
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
BoxLang Dynamic AWS Lambda - Japan Edition
Introduction to Ragic - #1 No Code Tool For Digitalizing Your Business Proces...
most interesting chapter in the world ppt
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx

How I learned to Stop Worrying and Love the inline-block