Modern CSS by Joe Attardi
Author:Joe Attardi
Language: eng
Format: epub
ISBN: 9781484262948
Publisher: Apress
.inner {
border: 5px solid green;
margin: 1rem;
}
</style>
<div class="container">
<div class="inner">Hello world!</div>
</div>
Listing 7-3Adding margin
Now there is a margin of 1rem between the inner and outer borders, as shown in Figure 7-4.
Figure 7-4Margin between the inner and outer borders
Like padding, using a percentage for the margin property will set the given percentage of the containing blockâs width as the margin.
Centering with margin: auto
The margin property also accepts the auto value. When the horizontal (left and right) margin is set to auto in a block or inline-block element, the element is centered horizontally within its containing element. The element takes up the specified width, and the margin is automatically distributed evenly between the left and right margins.
However, the same is not true for vertical margin. However, as we will see later, there are several other ways to vertically center a block-level element.<style>
.container {
background-color: red;
height: 5rem;
padding: 1rem;
width: 20rem;
}
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7791)
Grails in Action by Glen Smith Peter Ledbrook(7705)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6424)
Kotlin in Action by Dmitry Jemerov(5074)
WordPress Plugin Development Cookbook by Yannick Lefebvre(3851)
Mastering Azure Security by Mustafa Toroman and Tom Janetscheck(3337)
Learning React: Functional Web Development with React and Redux by Banks Alex & Porcello Eve(3091)
Mastering Bitcoin: Programming the Open Blockchain by Andreas M. Antonopoulos(2873)
The Art Of Deception by Kevin Mitnick(2613)
Drugs Unlimited by Mike Power(2475)
The Innovators: How a Group of Hackers, Geniuses, and Geeks Created the Digital Revolution by Walter Isaacson(2358)
Kali Linux - An Ethical Hacker's Cookbook: End-to-end penetration testing solutions by Sharma Himanshu(2317)
Writing for the Web: Creating Compelling Web Content Using Words, Pictures and Sound (Eva Spring's Library) by Lynda Felder(2267)
A Blueprint for Production-Ready Web Applications: Leverage industry best practices to create complete web apps with Python, TypeScript, and AWS by Dr. Philip Jones(2266)
SEO 2018: Learn search engine optimization with smart internet marketing strategies by Adam Clarke(2197)
JavaScript by Example by S Dani Akash(2141)
DarkMarket by Misha Glenny(2086)
Wireless Hacking 101 by Karina Astudillo(2081)
Hands-On Cybersecurity with Blockchain by Rajneesh Gupta(2001)
