我看了以前的类似问题,似乎没有得到我需要的结果。如何防止浮动div“跌落”?
这是布局我试着做...
的问题是,说的起源和具有图像的部分。
有一个包含div包含2个子div。一个孩子向左漂浮着文字,一个向右漂浮着影像。
当您缩放窗口时,我希望div也可以缩放。
问题是,当您将窗口缩放到某个点时,右边的孩子落在左边的孩子下面。
我试着让孩子的显示器:内联块和容器溢出:隐藏; white-space:nowrap,但是段落中的文本会在整个布局之外流动。
这里是代码...
<!DOCTYPE html>
<html>
<head>
<style>
body{
margin: 0;
padding: 0;
background-color: yellow;
}
#container{
width: 100%;
background-color: blue;
}
#main_content_container{
padding: 0px 20px 40px 20px;
margin: 0px auto;
max-width: 1090px;
background-color: white;
overflow: auto;
}
#main_content_left_col{
width: 65.1%;
margin: 0px 10px 0px 0px;
float: left;
}
#main_content_right_col{
width: 33%;
margin: 0px 0px 0px 10px;
float: right;
}
#history_pic{
width: 100%;
margin: 10px auto 0px auto;
}
p{
padding: 0px;
margin: 0px 0px 10px 0px;
font-family: 'Roboto', serif; font-weight: 300;
color: black;
font-size: 16px;
text-align: justify;
</style>
</head>
<body>
<div id="container">
<div id="main_content_container">
<div id="main_content_left_col">
<h1>ORIGINS</h1>
<h2>A look at the history of wave sliding</h2>
<p>The riding of waves has likely existed since humans began swimming in the ocean. In this sense, bodysurfing is the oldest type of wave-catching. Standing up on what is now called a surfboard is a relatively recent innovation developed by the Polynesians. The influences for modern surfing can be directly traced to the surfers of pre-contact Hawaii.</p>
<p>The art of surfing, called he'enalu in the Hawaiian language, was first described in 1769 by Joseph Banks on the HMS Endeavour during the third voyage of Captain James Cook. Surfing was a central part of ancient Polynesian culture and predates European contact. The chief (Ali'i) was the most skilled wave rider in the community with the best board made from the best tree. The ruling class had the best beaches and the best boards, and the commoners were not allowed on the same beaches, but they could gain prestige by their ability to ride the surf on their ratchet boards.</p>
<p>The sport was also recorded in print by other European residents and visitors who wrote about and photographed Samoans surfing on planks and single canoe hulls; Samoans referred to surf riding as fa'ase'e or se'egalu. Edward Treager also confirmed Samoan terminology for surfing and surfboards in Samoa. Oral tradition confirms that surfing was also practiced in Tonga, where the late king Taufa'ahau Tupou IV was the foremost Tongan surfer of his time.</p>
</div>
<div id="main_content_right_col">
<img id="history_pic" src="http://i1370.photobucket.com/albums/ag265/arsinek1/web_development/history_pic_zpsmy5pfaet.jpg" />
</div>
</div>
</div>
</body>
</html>
的工作,你可能想尝试删除'float'如果您还使用'直列block'考虑,同时具有目前通常是不必要的!尝试让布局在没有浮动的情况下正常工作。 – 2015-03-30 18:07:42
我做到了。文本从容器中流出,离开页面。 – Arsinek 2015-03-30 18:09:12
问题是你应该设置两个div属性位置内的所有inner-tags:relative; – 2015-03-30 18:10:04