Float
We can float HTML elements by giving them the following values;
none
– The element does not float. It is default value for any element.inherit
– The element inherits the value of float from its parent element.left
– The element floats to the left.right
– The element floats to the right.
1 2 3 |
.img1 { float: right; } |
Clear and Float
We can clear HTML elements by giving them the following values;
none
– Allows floating elements on both sides. This is defaultleft
– Does not allow floating elements on the left side.right
– Does not allow floating elements on the right side.both
– Does not allow floating elements on the both sides.inherit
– The child element inherits the clear value from its parent element.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
.a { float: left; width: 50px; padding: 0px; height: 50px; background-color:green; } .b { float: left; width: 50px; padding: 0px; height: 50px; clear:left; background-color:red; } |
Navigation menu
Navigation menu designed by implementing the list.
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 |
ul { list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: brown; } li { float: left; } li a { display: inline-block; color: white; text-align: center; padding: 16px 18px; text-decoration: none; } li a:hover { background-color: red; } .active { background-color: green; } |
Float none
1 2 3 |
img { float: none; } |
Web Layout
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
<html> <head> <style> * { box-sizing: border-box; } .header, .footer {
background-color: grey; color: white; padding: 20px; } .column { float: left; padding: 20px; } .clearfix::after { content: ""; clear: both; display: table; } .menu { width: 25%; } .content { width: 75%; } .menu ul { list-style-type: none; margin: 0; padding: 0; } .menu li { padding: 10px; margin-bottom: 10px; background-color: lightgrey; color: purple; } .menu li:hover { background-color: red; } </style> </head> <body> <div class="header"> <h1>T4-Tutorials</h1> </div> <div class="clearfix"> <div class="column menu"> <ul> <li><a href="https://t4tutorials.com/html"/>HTML</a></li> <li><a href="https://t4tutorials.com/css-tutorials/">CSS</a></li> <li><a href="https://t4tutorials.com/php-server-side-scripting-language-for-website-development"/>PHP</a></li> <li><a href="https://t4tutorials.com/keyword-worth-check-in-seo-search-engine-optimization"/>SEO</a></li> </ul> </div> <div class="column content"> <h1>About Learning</h1> <p>Welcome To T4-tutorials</p> <a href="https://www.T4tutorials.com">T4tutorials.com</a> </div> </div> <div class="footer"> <p>Thanks For visit us</p> </div> </body> </html> |