CSS Alignment
Dead Center
.dead-center { position: absolute; top: 50%; left: 50%; margin-top: -height/2; margin-left: -width/2; height: 70px; width: 250px; }
what is the difference between inline element & block element with text-align:center?
A block
element defaults to being the width of its container. It can have its width set using CSS, but either way it is a fixed width.
An inline
element takes its width from the size of its content text. (width: auto)
text-align is applicable to text inside block/inline elements only
To align block element (with specified width), use margin: 0 auto;
A simpler way to right-align a block-level element:
.block { background-color: blue; margin-left: auto; margin-right: 0; height: 100px; width: 250px; }
Absolute Alignment
.block { position: absolute; bottom: 20px; width: 100%; text-align: center; /* or left: 0; right: 0; // doesn't work in IE6,7 */ }
Vertical Align
Ref: What’s vertical align? – CSS Tricks
How do I vertically align text next to an image with CSS?
<div> <img style="width:30px;height:60px;vertical-align:middle"> <span style="">Works.</span> </div>
Understanding vertical-align, or “How (Not) To Vertically Center Content”‘
So how do I vertically-center something?!
#myoutercontainer2 { line-height:4em } /* Single line of text */
<style type="text/css"> #myoutercontainer { position:relative } #myinnercontainer { position:absolute; top:50%; height:10em; margin-top:-5em } </style> ... <div id="myoutercontainer"> <div id="myinnercontainer"> <p>Hey look! I'm vertically centered!</p> <p>How sweet is this?!</p> </div> </div>
How to properly vertically align an image
.frame { margin: 1em 0; height: 35px; width: 160px; border: 1px solid red; position: relative; } img { max-height: 25px; max-width: 160px; position: absolute; top: 0; bottom: 0; left: 0; right: 0; margin: auto; background: #3A6F9A; }
Altogether: 5 methods to vertically center any element
Ref: Horizontally Centered Menus with no CSS hacks
2019
Hoàng Hữu Thường
Danang International Marathon 2019 - An Amateur Experience
2018
You made me feel that way
"I hate Monday"
2017
When the abnormal becomes normal
Confidence
Em à
7 things I learn on my 3 weeks in the UK
Ba Que?
No Bad Publicity
Lose Battles to Win War
A 6-day Boracay Trip on April 2017
It sucks to be a NICE guy!
Philosophy
2016
Drinking Water
"Does this book change your life?"
Awesome People
Proud
Who are you?
Semarang & Yogja Trip
A Chinese Businessman
Một dân tộc yếu
My 3rd Trip to Bangkok
Ideas
The WAR of ART
Success 2016
Too Easy with Yourself
Read
Về sự xuống cấp...
Nếu được làm Thủ Tướng, tôi sẽ làm gì?
My First Trip to Taiwan
Intimacy
What I’m Doing Now
Why don’t you write anymore?
Loyal Friends
An Ambivert
My Money Rules
A crazy 2015
2015
The Hunger
"What are you seeing me for?"
#love #lasts
Luang Prabang & Seam Reap Trip
Principle vs Rules
"Talent"
Cậu
2015's Resolutions
999 Rules for my unborn Children
Huế Thương
2014
"Splash Page"'s Reason
Design Problems
A One-Sentence Journal
Deeply Grateful
What I love
Yangon Trip: Wedding
Thỏi vàng & bãi đất
Security & Obscurity
10 Math Graduation Questions
"What makes you proud of yourself?"
Vết Cắn
My Setup: Tools Review
Dead Money
Love Stories
#worldcup2014
E-books
Better Management
2046
Third affair
Thời Gian
Top Wordpress Plugins
My Ideal Day
It was never tougher!
"Financial Freedom"?
Patience!?
Escape
Lead but Lead Who?
Bro
Do something that lasts!
My Online Personal Development Space
2014's resolutions
"Let Her Go"
Stop... !?
Dog shit
My Definition of a Loser
2013 Year in Review
2013
Rexy.me goes minimalist
Freedom in Discipline
Quick Fixes
Trang & Ngọc
December 2013 Highlight
Ikea - Unwrap Xmas
"No Choice"
It's for me
Millionaire Mind Intensive 2013
November 13 Highlight
Bên Thắng Cuộc - Đức Huy
Vo Nguyen Giap & an old story
"Be water, my friends"
October 13 Hightlight
First times
Comparison
"We Don't Get What We Want..."
Promises
Ubuntu Edge
The Billionaire Club
Walk the talk
You only need to believe in yourselves
4 Types of People
girls in relationship!?
#4yearsinsingapore
Too many choices
"What do you do after work?"
My Loyalty #4yearsinsingapore
Happy Traveling
New Vocabs
I learn them the hard way
4 years in Singapore
An interview with my cousin
Dân Chủ
Work
The fear
10 songs that keep you motivated for life
The Secret Overview
What I wish I had done
CSS Alignment
Nothing to be ashamed of
blame, I take it all!
Ours
Rexy.me 1.5 years look back
Pimsleur method
My Habits
Xúc cảm 2
Xúc cảm 1
Just a note
Tại sao bạn phải học Tiếng Anh? (Phần 1)
The Forgetten Lesson Intro
The Curly's Law
2013's Resolution
How to win friends & influence people
Some Notes as A Web Dev
The Magic of Thinking Big Overview
Malacca Trip
Uncopyright
2013 New Year Wishes and Promises
2012
When I stop...
What's Personal Development?
Huu Thinh House Vision
English Idioms
The 7 Habits of Highly Effective People Overview
Life is fun and Success is easy
Come on Singaporeans
Good Reads
You should have a blog!
Rexy Theme
It's time to banish Internet Explorer
Never Eat Alone
My dishes
My Life Map
Give
You must have breakfast!
My Dream Girl
How to keep getting motivated
Italy go through the European Cup final
Get Anyone To Do Anything Overview
The Red Devils
National Achiever Congress 2012
Common Sense: common, make sense & wrong!
April-May Journals 2012
Jim Rohn
Sucking less everyday
Damn, People Still Think A Day's Got "24 hours"!
66 things to do before 22
How to Do What You Love
Những câu nói ấn tượng (I)
Best Practices: HTML
Semantic & Un-semantic Class Name Examples
Hãy tôn trọng
Nguyễn Cao Kỳ: Ngày ấy & Bây giờ
Nguyễn Cao Kỳ
XYZ Site Intro
2012 New Year's Resolutions
2011
My Drawings
Về những lần đầu tiên
CakePHP tips
So why are you still single?
Bức thư tình cuối cùng
Huế Mù Sương
2011 New Year's Resolutions
2010
Why Linux, not Windows
what the hell is Facebook playing around?
WikiLeaks remarks
Money won't make you rich
The Future of English
What's love?
"What have you learned?"
30 things every man should do by 30
25 things every man should do by 25
Anh Yêu Em Nhiều Lắm
Empathy
Italy: Behind the early exit!
nghèo
World Cup 2010 [live]
Huế
You
2007
Welcome 2007!
2006
Welcome to my blog
Semantic & Un-semantic Class Name Examples
Inspired by Chris Coyier article, What Makes For a Semantic Class Name?, @ css-tricks.com.
< div class = "column_1" ></ div > |
Unsemantic. Unless used in Grid-based system.
< div class = "footer" ></ div > |
Semantic. Yet consider using <footer> tag (& other semmantic HTML5 elements)
< div class = "largeText" ></ div > |
Un-semantic. This is specifying. Why should the text be larger? To “stand-out” or to “highlight” – consider using <mark> tag?
< div class = "priority-2" ></ div > |
Semantic. It’s like the idea of using <h1 />, <h2 />,…, <h6 />
< div class = "clearfix" ></ div > |
Unsemantic yet Acceptable in this case. Only name such similar un-semantic classes if only they’re pre-defined such as ir (image-replacement), left (float left) & some theme colors, etc.
< div class = "copyright" ></ div > |
Semantic. Some other class named of similar use are: “tweets”, “pagination”, “admin-nav”, “sidebar”.
< p class = "introp" ></ p > |
Unsemantic. Classitis. It can be selected by CSS: .intro p:first-child
< div class = "left" ></ div > |
Unsemantic. Perhaps in the future, you may wanna this element on the right instead.
< div class = "success" ></ div > |
Semantic. It usually works in conjunction with other class to best describe the element content (or status of content): class=”success message”, “success feedback”, “fail message”, etc. Don’t use 1 class in such cases like “redBigError” or “renderError”. They are not reusable.
< a class = "link" href = "#" ></ a > |
Unsemantic. Classitis. It should be more specific in this case like: book-link, button, etc.