我正在尝试将页面分成两半,以便左侧有一个图像,右侧有文本。但由于某种原因,我遇到了问题。有人可以引导我在乘坐方向。如何使用CSS将页面分成两半?
预先感谢您!
HTML:
<section>
<div class="col-1"></div>
<div class="col-2">
<div class="article">
<h2 class="top"> The Title </h2>
<p> This is a subtitle </p>
<h1> Design Name </h1>
<h2 class="bottom"> copyright 2014 </h2>
</div>
</div>
</section>
CSS:
html {
font-family: 'Helvetica', sans-serif;
font-size: 10px;
-webkit-font-smoothing: antialiased;
}
section {
position: absolute;
width: 50%;
height: 100%;
overflow: hidden;
}
.col-1 {
left: 0;
width: 50%;
height: 100%;
background: url(http://MyImageLink);
background-position: center center;
background-size: cover;
}
.col-2 {
right: 0;
background: #000015;
}
.article {
color: #fff;
text-align: center;
}
* {
position: absolute;
width: 100%;
}
h1 {
bottom: 125px;
text-transform: uppercase;
font-size: 1.4rem;
font-weight: 300;
letter-spacing: .6rem;
text-indent: .6rem;
}
h2 {
font-size: .8rem;
font-weight: 800;
letter-spacing: .1rem;
text-indent: .1rem;
text-transform: uppercase;
}
.top {
top: 100px;
}
.bottom {
bottom: 100px;
}
p {
top: 50%;
margin: -1em 0 0;
font-size: 3.5rem;
font-weight: 800;
}
你能用小提琴重现您的问题现场操场。 – Benjamin 2014-09-10 08:42:54
您是否在示例中缺少一些HTML?我期待在你的标记中看到col-1? – 2014-09-10 08:43:23
是的,对不起,当我在我的问题中粘贴代码时,我忘了缩进,所以它没有出现在我的问题中。这是我得到的:http://jsfiddle.net/fw3nw6gm/1/ – Surge 2014-09-10 08:51:07