문제
아래 코드를 형식화하는 방법을 알아 내서 처음 두 블록이 나란히 표시되도록 한 다음 그 아래에 세 번째 중심을 표시합니다. CSS와 함께 리스팅 스타일을 사용하여 포맷하려고 시도했지만 실제로는 효과가없는 것 같습니다.
도움/제안?
<div class="inauguration-content">
<h3>Inauguration</h3>
Friday, April 17, 2009<br />
3:00 p.m.<br />
Sarkus-Busch Theater<br />
Robert McLaughlin College Center</p>
<h3>Inaugural Gala</h3>
7-11 p.m.<br />
Robert McLaughlin College Center<br />
Featuring hors d'oeuvres, open bar and dinner and dessert stations<br />
Entertainment by Frankie Michaels<br />
Cocktail Attire Recommended<br />
Tickets are $100 per person<br />
Proceeds benefit the Herkimer County College Foundation</p>
<h3>Important Information for Delegates</h3>
<a href="http://www.herkimer.edu/admissions/directions/" target="_blank">Direction to HCCC</a><br />
<a href="http://www.herkimer.edu/pdfs/campusmap.pdf" target="_blank">Campus Map</a><br />
<a href="http://www.herkimer.edu/admissions/hotels/" target="_blank">Lodging Information</a><br />
Delegates marching in the Inaugural Procession should report to the Open Student Area, first floor of the Library Complex at 2:00 p.m. for robing and assembly.<br />
Delegates are expected to furnish their own academic regalia.</p>
</div>
해결책
세 개의 div를 만들 수 있습니다.
- 첫 번째 div (왼쪽 상단)는 컨테이너의 50% (예 : 뷰포트)에 너비를 설정하고 왼쪽으로 뜨다.
- 두 번째 div (오른쪽 상단)은 컨테이너의 50% (예 : 뷰포트)와 폭이 설정되어 있습니다. 오른쪽으로 떠 다니십시오.
- 세 번째 div (하단 센터)는 컨테이너의 100% (예 : Viewport)에 WITDH가 설정되어 있습니다. CSS의 CLEAR : 둘 다 사용하십시오. 두 수레 중 가장 높은 바로 아래에 위치합니다. 중앙에 더 작은 너비 (예 : 50% 또는 20EM)를 사용하고 CSS 마진 왼쪽 및 마진 오른쪽을 자동으로 설정하십시오 (아래 예제 참조).
위의 것은 3 개의 DIV 중 하나 내부의 모든 랩핑 및 수직 성장 (사용자의 글꼴 크기가 증가함에 따라)을 수용하기 위해 3 개의 DIV를 동적으로 포장합니다.
<html><body>
<div style="width:50%; float:left">
Inauguration<br/>
Friday, April 17, 2009<br/>
3:00 p.m.<br/>
Sarkus-Busch Theater<br/>
Robert McLaughlin College Center
</div>
<div style="width:50%; float:right">
Inaugural Gala<br/>
7-11 p.m.<br/>
Robert McLaughlin College Center<br/>
Featuring hors d'oeuvres, open bar and dinner and dessert stations<br/>
Entertainment by Frankie Michaels<br/>
Cocktail Attire Recommended<br/>
Tickets are $100 per person<br/>
Proceeds benefit the Herkimer County College Foundation
</div>
<div style="width:50%; margin-left:auto; margin-right:auto; clear:both">
Important Information for Delegates<br/>
Direction to HCCC<br/>
Campus Map<br/>
Lodging Information<br/>
Delegates marching in the Inaugural Procession should report to the Open Student Area, first floor of the
Library Complex at 2:00 p.m. for robing and assembly.<br/>
Delegates are expected to furnish their own academic regalia.
</div>
</body></html>
다른 팁
재미를 위해, 여기에 목록을 사용하고 싶었던 레이아웃이 있습니다.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>container Title</title>
<style type="text/css" media="screen">
body {
font-family:Georgia;
}
#container {
width:700px;
margin:0 auto;
}
ul {
display:block;
margin:0;
padding:0px;
width:50%;
float:left;
}
ul.full {
margin:0 auto;
float:none;
clear:both;
padding-top:5px;
}
ul li {
list-style-type:none;
margin:0;
padding:0;
padding-left:10px;
}
</style>
</head>
<body>
<div id="container">
<ul>
<li><h4>Inauguration</h4></li>
<li>Friday, April 17, 2009</li>
<li>3:00 p.m.</li>
<li>Sarkus-Busch Theater</li>
<li>Robert McLaughlin College Center</li
></ul>
<ul>
<li><h4>Inaugural Gala</h4></li>
<li>7-11 p.m.</li>
<li>Robert McLaughlin College Center</li>
<li>Featuring hors d'oeuvres, open bar and dinner and dessert stations</li>
<li>Entertainment by Frankie Michaels</li>
<li>Cocktail Attire Recommended</li>
<li>Tickets are $100 per person</li>
<li>Proceeds benefit the Herkimer County College Foundation</li>
</ul>
<ul class="full">
<li><h4>Important Information for Delegates</h4></li>
<li>Direction to HCCC</li>
<li>Campus Map</li>
<li>Lodging Information</li>
<li>Delegates marching in the Inaugural Procession should report to the Open Student Area, first floor of the Library Complex at 2:00 p.m. for robing and assembly.</li>
<li>Delegates are expected to furnish their own academic regalia. </li>
</ul>
</div>
</body>
</html>
나는 이것을 목록으로 스타일링하지 않고, divs 만 사용하십시오.
<style type="text/css">
.left { float:left; }
.right { float:right; }
.half { width:50%; }
.centered { text-align:center; }
// from http://www.webtoolkit.info/css-clearfix.html
.clearfix:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}
.clearfix {
display: inline-block;
}
html[xmlns] .clearfix {
display: block;
}
* html .clearfix {
height: 1%;
}
</style>
<div class="clearfix">
<div style="left half">
<strong>Inauguration</strong><br />
Friday, April 17, 2009<br />
3:00 p.m.<br />
Sarkus-Busch Theater<br />
Robert McLaughlin College Center<br />
</div>
<div style="right half">
<strong>Inaugural Gala</strong><br />
7-11 p.m.<br />
Robert McLaughlin College Center<br />
Featuring hors d'oeuvres, open bar and dinner and dessert stations<br />
Entertainment by Frankie Michaels<br />
Cocktail Attire Recommended<br />
Tickets are $100 per person<br />
Proceeds benefit the Herkimer County College Foundation<br />
</div>
</div>
<div class="centered">
<strong>Important Information for Delegates</strong><br />
Direction to HCCC<br />
Campus Map<br />
Lodging Information<br />
Delegates marching in the Inaugural Procession should report to the Open Student Area, first floor of the Library Complex at 2:00 p.m. for robing and assembly.<br />
Delegates are expected to furnish their own academic regalia.<br />
</div>
<div style="width:49%; float:left"><p>
Inauguration<br/>
Friday, April 17, 2009<br/>
3:00 p.m.<br/>
Sarkus-Busch Theater<br/>
Robert McLaughlin College Center</p>
</div>
<div style="width:49%; float:left"><p>
Inaugural Gala<br/>
7-11 p.m.<br/>
Robert McLaughlin College Center<br/>
Featuring hors d'oeuvres, open bar and dinner and dessert stations<br/>
Entertainment by Frankie Michaels<br/>
Cocktail Attire Recommended<br/>
Tickets are $100 per person<br/>
Proceeds benefit the Herkimer County College Foundation</p>
</div>
<div style="width:50%;margin:auto "><p>
Important Information for Delegates<br/>
Direction to HCCC<br/>
Campus Map<br/>
Lodging Information<br/>
Delegates marching in the Inaugural Procession should
report to the Open Student Area, first floor of the
Library Complex at 2:00 p.m. for robing and assembly.<br/>
Delegates are expected to furnish their own academic regalia.</p>
</div>
제휴하지 않습니다 StackOverflow