/ Published in: CSS
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/* GENERAL CSS DOCUMENT */ body { color:#000; background:#f5f5f5; font-family:"Helvetica Neue", Arial, Helvetica, sans-serif; } div#background { position: absolute; background: #CCC; width: 960px; /* reduced to account for padding */ height: 100%; top: 30px; left: 50%; /* DIV-BASED CENTERING PART 1 */ margin-left:-490px; /* DIV-BASED CENTERING PART 2 */ padding: 10px; /* enforces distance between DIV edge and contents */ } div#container { position: relative; background:#f5f5f5; height: 80px; /* decreased to account for XXX */ width: 80px; /* decreased to account for XXX */ margin: 10px; /* positions DIV relative to parent container, does not affect actual size */ padding: 10px; /* positions DIV contents relative to interior border, does affect actual size */ /* border: 1px solid black; borders also affect actual size, test by uncommenting*/ float: left; } /* note how the final position is a mix of background padding and plainbox padding */