HTML CSS examples for CSS Layout:Position
Trouble positioning elements using float in a responsive design
<html> <head> <title>Lorem ipsum dolor </title> <meta name="viewport" content="width=device-width, initial-scale=1"> <style id="compiled-css" type="text/css"> h1 {<!--from ww w .ja v a 2s .c om--> background-color:Chartreuse; } @media screen and (min-width: 768px) and (max-width: 909px) { .wrapper { width:601px; outline:2px dotted blue; } .image { width:601px; outline:2px dotted blue; } .content1 { float:left; width:301px; outline:2px dotted blue; } .content2 { width:301px; float:left; outline:2px dotted blue; } } @media screen and (min-width: 909px) { .wrapper { width:901px; outline:2px dotted blue; } .image { width:601px; float:left; outline:2px dotted blue; } .content1 { float:left; width:601px; outline:2px dotted blue; } .content2 { width:301px; margin-left:601px; outline:2px dotted blue; } } </style> </head> <body> <div class="wrapper"> <h1>Lorem ipsum </h1> <div class="image"> <img src="https://www.java2s.com/style/demo/Firefox.png"> </div> <div class="content1"> <b>Lorem ipsum do</b>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper molestie lacus sed fermentum. Aliquam erat volutpat. Vestibulum tortor neque, ornare vitae tempor hendrerit, luctus at neque. Phasellus sed quam pharetra, tincidunt tortor in, pharetra nisl. Maecenas ali </div> <div class="content2"> <b>Lorem ipsum do</b>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ullamcorper molestie lacus sed fermentum. Aliquam erat volutpat. Vestibulum tortor neque, ornare vitae tempor hendrerit, luctus at neque. Phasellus sed quam pharetra, tincidunt tortor in, pharetra nisl. Maecenas aliquam luctus mauris, vitae venenatis diam imperdiet vel. Donec tortor diam, pretium vitae nibh vitae, consectetur lacinia sem. Proin luctus facilisis volutpat. Ut semper sit amet purus quis ornare. Quisque lobortis neque vitae tempor iaculis. Aliquam erat volutpat. Mauris tincidunt eget lacus eget pulvinar. Suspendisse potenti. Maecenas </div> </div> </body> </html>