Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
glenn romaniuk
33,738 Pointshow to float a div to the horizontally/left and vertically/middle of a paragraph
have an html with a div and a paragraph if i float the div the text wraps i want to move the div down to the middle of the paragraph when i change the margin i pushes the div down but the text does not wrap around the top of the div how is this done?
4 Answers
James Ingmire
11,901 PointsDo not put a margin on the div to move it as this is why the text will not wrap. You need to place your div by using top, left etc
top: 150px;
left: 100px;
To be honest you need to upload your code if you want help; as your question is not detailed enough.
glenn romaniuk
33,738 PointsHere make the mydiv appear on the left side in the center of the paragraph make the text wrap around it
<div id="mydiv"></div> <p>Lorem ipsum dolor sit amet, eu cum esse voluptatibus, nec an dolore prodesset similique, alterum conceptam vituperata cum cu. Eum ea labore percipit principes. Ex vix purto natum phaedrum, vim mentitum partiendo interpretaris cu. Ea aliquip tamquam his. Falli choro postea nam ea, ea usu nonumes repudiare. Cum sale omnis dicit et, soluta laoreet antiopam sit at, sit in quot propriae tincidunt. Vis te torquatos honestatis. Per malis primis id, inani mnesarchum ut vel. Et eam harum definiebas definitiones, usu feugiat reprimique te, in nam dicant dissentiunt disputationi. Nullam verear singulis et eam, usu impetus denique dissentiunt cu. Pro vidisse consulatu delicatissimi ei, duis laoreet docendi id vel, cu probatus accommodare vix. Ne mei tollit hendrerit. Sit dolorem pericula cu, vis erat paulo adversarium at. Cu porro officiis mea. Ius ad solum definiebas assueverit, an audiam iuvaret persequeris ius. Ad eum minim nullam consulatu, eam pericula electram id. Vim debet deserunt dissentiunt ne, sed an mentitum mandamus ullamcorper. Usu nonumes admodum at. Ne nihil graeci dicunt ius, no aeque decore usu, at novum regione inciderint quo. Ius at putent omnium integre, dicant graeci conceptam mei ne. Id facer alterum has, ponderum delicatissimi qui ea. Mea inermis scaevola concludaturque at, eam oratio tempor doctus in. Quo ea vidit ipsum, nisl appareat postulant ea pri. No est tota rebum persecuti, eu sea suavitate tincidunt. Ius paulo numquam ceteros cu, his eligendi intellegam ne.</p>
Ricardo Hill-Henry
38,443 PointsNot sure why this was originally posted as a comment..
Floats are used mainly for either floating an object to the left, or right of a container; not putting something in the middle.
Anything below a floated object wraps, not those above. If you want to get text to wrap around the top, you have to change your order of the content in your HTML I'd have to see your code to give you some better advice.
Ricardo Hill-Henry
38,443 PointsRicardo Hill-Henry
38,443 PointsNot sure why this was posted as a comment..