PeterPam
PeterPam

Reputation: 437

Split screen in two parts with different width

i'm trying to split the page in 2 parts, but with different sizes. With the following code, i get 2 parts, but with same size.

http://jsfiddle.net/aL78z6kf/

The html part is:

<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>

And the Css is:

.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%;
}

Is it possible to do? Thanks in advance

Upvotes: 0

Views: 2310

Answers (1)

Karuppiah RK
Karuppiah RK

Reputation: 3964

JsFiddle

Remove width:50% from .split class. And add width properties (whatever you want) to .left and .right class.

/* Control the left side */
.left {
  left: 0;
  background-color: orange;
  width: 30%;
}

/* Control the right side */
.right {
  right: 0;
  background-color: red;
  width: 70%;
}

Upvotes: 1

Related Questions