comeze.com
域名年龄: 15年26天HTTP/1.1 200 OK 访问时间:2011年10月23日 19:46:40 语言环境:PHP/5.2.17 文件大小:4778 连接:关闭 类型:text/html
HomeSitesOther WorksContactAbout me This website is a showcase of my digital creativity ranging from C++ to wallpapers to website development, and a bit of photography as well. Feel free to have a look around and leave a comment. Bloody Floats! So, if you're new to web design like myself, you've probably come across quite a few problems when designing layouts. One of the most common problems i find myself stuck on is the hanging float; this is where you've floated a <div> which is inside a container <div>, and the container <div> fails to expand and encase the floated <div>. There have been many solutions to this problem posted all over the internet, but today i offer my own solution (even as inelegant as it is). The Solution My solution is to have a floated sub-container <div> within container <div>, because floats always stretch to encase their child elements. If you have a look at the CSS for this page, you can see i've used a container (#MainWrapper), and a sub-container (#SubWrapper) where the main container is used to position the sub-container on the page. The CSS would look something like this for a centred <div> with: A floated container inside Two divs horizontally aligned next to each other #Main { margin-left: auto; margin-right: auto; width: 500px; } #Sub { float: left; width: 498px; border: 1px solid black; padding: 5px; background-color: #EEE; } #Left { float: left; width: 308px; border: 1px solid black; } #Right { margin-left: 315px; width: 181px; border: 1px solid black; } The end result looks something like this: This is the left hand side div with extra spaces This is the right hand side div Sadly, this leads to the problem of having two unequal sized <div>'s, and also another problem to do with the main container. See my next post on how to solve these using javascript. My deviantART page FunkyZoo Urban Guerillas ColourLovers Copyright David F 2010
© 2010 - 2020 网站综合信息查询 同IP网站查询 相关类似网站查询 网站备案查询网站地图 最新查询 最近更新 优秀网站 热门网站 全部网站 同IP查询 备案查询
2025-07-13 07:18, Process in 0.0077 second.