Center parent div with dynamic and set width child divs
2014-12-12 03:37
471 查看
http://stackoverflow.com/questions/26317115/center-parent-div-with-dynamic-and-set-width-child-divs
Centering a Div of Unknown Width
When the div widths are variable, the centering technique below works well. It uses an outer and inner wrapper.
The outer wrapper div is set to text-align:center.
the inner wrapper is inline-block, and responds to the text-align:center from the outer wrapper. It uses text-align:left to
overwrite the text center from the first wrapper.
The logo and menu are floated so they will be next to each other.
This is a good technique for centering when the widths can be variable.
Centering a Div of Unknown Width
When the div widths are variable, the centering technique below works well. It uses an outer and inner wrapper.
The outer wrapper div is set to text-align:center.
the inner wrapper is inline-block, and responds to the text-align:center from the outer wrapper. It uses text-align:left to
overwrite the text center from the first wrapper.
The logo and menu are floated so they will be next to each other.
This is a good technique for centering when the widths can be variable.
相关文章推荐
- CCLabelTTF with fixed width and dynamic height solution
- Codeforces Round #250 (Div. 2)——The Child and Set
- Codeforces #250 (Div. 2) B. The Child and Set
- Codeforces Round #250 (Div. 2)——The Child and Set
- Codeforces Round #250 (Div. 2) -B. The Child and Set
- Parent-Child Data Manipulations with GridView and DetailsView control
- codeforces --- Round #250 (Div. 2) B. The Child and Set
- How do I get dynamic DataSources with iBATIS and Spring?
- 配置ASA Dynamic IPsec IOS and Dynamicallyaddressed PIX with NAT
- 页面各元素位置和距离对象关系图解。 (深入document.documentElement、body.clentTop、div.scrollTop、div.scrollHeight、body.offsetWidth and so on)
- JavaScript Timers with setTimeout and setInterval
- (FW: From MSDN)Creating a Child Process with Redirected Input and Output
- How To Quickly Set Up Ubuntu 8.04 loaded with Erlang, Mochiweb and Nginx
- Examples of Inherited with and without explicit parent method names
- 关于APACHE进程重启问题的分析 Parent: child process exited with status 3221225477 -- Restarting
- the question regarding "Parent and Child Latches", version 11.1.0.7
- [转]Fun with Locked Pages, AWE, Task Manager, and the Working Set…
- Set Height and Width Pie Chart
- ASP.NET2.0 Menu Control set static item selected when select its child dynamic items
- Allow user to scroll and maintain position with "Scroll To Bottom of the Div" example