Setup a portion of html page as scrollable?

Joined
Jan 7, 2025
Messages
3
Reaction score
0
Hi. I don't know too much html, but I want to setup the following layout to my page:

html_layout.png

To split the page in two, I wrote:

HTML:
<style>
body {
    font-family: Arial;


/*    color: #111111;
    background-color:#f0fae4;*/


    color: #f9f9ff;
    background-color:#161B1F;
}


.split {
    height: 100%;
    width: 50%;
    position: fixed;
    z-index: 1;
    top: 0;
    overflow-x: hidden;
}


.left {
    left: 0;
/*    background-color: RGB(240, 250, 228);*/
}


.right {
    right: 0;
/*    background-color: RGB(240, 250, 228);*/
}

and

HTML:
<body>
        <div class="split left">
            .. content layout 1
        </div>
        <div class="split right">
            <div class="so">
                some content layout 2
            </div>
            <div class="layout3">
                .... long content ...
            </div>
    </body>

how can I setup Layout 3 to be scrollable, but not Layout 2?
 
Joined
Jul 4, 2023
Messages
553
Reaction score
72
Check this out:
HTML:
<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

  </head>
  <body>
    <div class="split left">
      .. content layout 1
    </div>
    <div class="split right">
      <div class="layout-2">
        some content layout 2
      </div>
      <div class="layout-3">
        .... long content ...

        <!-- for demonstration -->
        <p style="height: 2000px"></p>
      </div>
    </div>
  </body>
</html>
CSS:
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  font-family: Arial;
  color: red;
  background-color: #161B1F;
}
.split {
  height: 100dvh; /* in <head> needs <meta name="viewport" ...> */
  width: 50dvw;   /* in <head> needs <meta name="viewport" ...> */
  position: fixed;
  top: 0;
  bottom: 0;
  overflow-x: hidden;

  background-color: lightcoral; /* for demonstration */
}

.left {
  left: 0;
}
.right {
  right: 0;
}
.layout-2,
.layout-3 {
  padding: .5rem;
}
.layout-2 {
  height: 10%;
  background-color: lightsalmon; /* for demonstration */
}
.layout-3 {
  height: 90%;
  overflow-x: auto;
  background-color: lightskyblue; /* for demonstration */
}
1736331799763.png
 
Last edited:
Joined
Jul 4, 2023
Messages
553
Reaction score
72
How about trying CSS Grid?
HTML:
<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

  </head>
  <body>
    <div class="container">
      <div class="layout layout-1">
        .. content layout 1
      </div>
      <div class="layout layout-2">
        some content layout 2
      </div>
      <div class="layout layout-3">
        .... long content ...

        <!-- for demonstration -->
        <p style="height: 2000px"></p>
      </div>
    </div>
  </body>
</html>
CSS:
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  font-family: Arial;
  color: white;
  height: 100dvh;
  overflow-x: hidden;
}
.container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 3fr;
  gap: 0px;
  grid-template-areas:
    "layout-1 layout-2"
    "layout-1 layout-3";
 
  height: 100%;
}
.container .layout {
  padding: .5rem;
}
.layout-1 { grid-area: layout-1; }
.layout-2 { grid-area: layout-2; }
.layout-3 { grid-area: layout-3; }

.layout-1 {
  overflow-x: hidden;
  background-color: lightcoral; /* for demonstration */
}
.layout-2 {
  background-color: lightsalmon; /* for demonstration */
}
.layout-3 {
  overflow-x: auto;
  background-color: lightskyblue; /* for demonstration */
}

1736342203597.png
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,137
Messages
2,570,802
Members
47,349
Latest member
eixataze

Latest Threads

Top