我试图将页面拆分为两部分,但尺寸不同。使用以下代码,我得到2个部分,但大小相同。
html部分是:
<div class="split left">
<div class="centered">
<h2>Jane Flex</h2>
<p>Some text.</p>
</div>
</div>
<div class="split right">
<div class="centered">
<h2>John Doe</h2>
<p>Some text here too.</p>
</div>
</div>
而Css是:
.split {
height: 100%;
width: 50%;
position: fixed;
z-index: 1;
top: 0;
overflow-x: hidden;
padding-top: 20px;
}
/* Control the left side */
.left {
left: 0;
background-color: orange;
}
/* Control the right side */
.right {
right: 0;
background-color: red;
}
/* If you want the content centered horizontally and vertically */
.centered {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
}
/* Style the image inside the centered container, if needed */
.centered img {
width: 150px;
border-radius: 50%;
}
有可能吗?提前致谢
从width:50%
类中删除.split
。并向.left
和.right
类添加宽度属性(无论你想要什么)。
/* Control the left side */
.left {
left: 0;
background-color: orange;
width: 30%;
}
/* Control the right side */
.right {
right: 0;
background-color: red;
width: 70%;
}