我试图打破我的列对之间的界限并且确实遇到了一些麻烦。我希望第一列在页面的中心,第二个较小的列在它的右边。
这将在这对列下方重复。
<html>
<head>
<title>Choose to Give</title>
<link rel="stylesheet" type="text/css" href="web.css" />
</head>
<body>
<ul class="nav">
<li><a href="/home/">Home</a></li>
<li><a href="/about_us/">About</a></li>
<li><a href="/foundations/">Foundations</a></li>
<li><a href="/forums/">Forums</a></li>
<li><a href="/contact/">Contact</a></li>
</ul>
<div class="column1of2">
<h2>
Do something that matters.
blah blah
</h2>
</div>
<div class="column2of2">
<h2>
Top user contributions.
</h2>
</div>
<br>
<div class="column1of2">
<h2>
Random title here
blah blah
</h2>
</div>
<div class="column2of2">
<h2>
Top company contributions.
</h2>
</div>
</body>
</html>
然后是 CSS。
body {
background-color:#66FF33;
font-size: 8pt;
color: black;
text-align: left;
}
.nav{
border:10px solid black;
background-color: white;
border-width:10px 0;
list-style:none;
padding:0;
margin-top: 10%;
text-align:center;
font-size: 12pt;
}
.nav li{
display:inline;
}
.nav a{
display:inline-block;
padding:10px;
}
h1 {
text-align: left;
color: black;
background-color: white;
padding: 30px;
border-style: solid;
border-width: 10px;
border-left-width: 10px;
border-right-width: 10px;
border-color: black;
border-radius: 5px;
}
h2 {
text-align: left;
color: black;
background-color: white;
padding: 30px;
border-style: solid;
border-width: 10px;
border-left-width: 10px;
border-right-width: 10px;
border-color: black;
border-radius: 5px;
}
.column1of2 {
float: left;
width: 30%;
left-margin: 10%;
}
.column2of2 {
float: right;
width: 15%;
right-margin: 2%;
}