1 2 3 4 5 6 7 8 9 10 11 12 13 |
<style> .box1{ width:400px; height:100px; background:#D7E5F0; border:.1em solid red; padding:10px; } </style> </body>
|
main div
I will add four divs inside the main div, floating two of them to the left, others to the right by using float property, and using padding property to make some distance between div elements.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
<style> .main_box{ width:400px; height:100px; background:#D7E5F0; border:.1em solid red; padding:10px; } .inner_box{ width:40px; height:30px; background:#FFF0F0; border:.1em dotted green; padding:10px; margin:10px; font-size:12px; color: black; font-weight: bold; } .left_box{ float: left; } .right_box{ float: right; } </style> |
A
left
left
B
left
left
C
right
right
D
right
right
How to expand the main container div.
the last example was good to show how to put some elements inside the main div, but what if the inner elements were big and the main div height didn't expand to still hold them.
A
left
left
B
height:100px;
height:100px;
C
right
right
D
right
right
in the case we should replace the fixed height of the main div with the
display: inline-block; property.
1 2 3 4 5 6 7 8 9 |
<style> .box1{ width:400px; display:inline-block; background:#D7E5F0; border:.1em solid red; padding:10px; } </style> |
A
left
left
B
height:100px;
height:100px;
C
right
right
D
right
right
If this post was good and helpful for you, Please give it Like.
.
0 comments:
Post a Comment