Designing a layout with one box on top and two beneath it, covering the entire page, can be achieved by following these steps

I am currently working on a project where I want to divide the screen into three sections. One section will cover half of the screen to display an image slider, and the remaining half will have two sections which is already done. However, now I need to add another section on top that does not display the image slider. Can someone please assist me with this issue?

Here is my current code:

<head runat="server">
    <title></title>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <style>
        body {
            font-family: Arial;
            color: white;
        }

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

        .left {
            left: 0;
            background-color: #ff6a00;
        }

        .right {
            right: 0;
            background-color: #ffd800;
        }

        .centered {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            text-align: center;
        }

            .centered img {
                width: 150px;
                border-radius: 50%;
            }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <div class="split left">
            <div class="centered">
                <h2>Blood Donor</h2>
                <p><a href="../BloodDonor/Registration/Registration.aspx">Go To Registration</a></p>
            </div>
        </div>

        <div class="split right">
            <div class="centered">
                <h2>Blood Seeker</h2>
                <p><a href="../BloodSeeker/Registration/Registration.aspx">Go To Registration</a></p>
            </div>
        </div>

    </form>
</body>

If anyone can provide assistance, I would greatly appreciate it. Thank you for your time.

Answer №1

This layout is created using CSS Grid, which is a 2D version of Flexbox:

.main {
  display: inline-grid;
  height: 200px;
  width: 400px;
  grid-template-rows: 50% 50%;
  border: green solid 2px;
}
.main .level1 {
  border: blue solid 2px;
  display: flex;
}
.main .level1 .level2 {
  border: red solid 2px;
  flex-basis: 50%;
}
<div class="main">
  <div class="level1"></div>
  <div class="level1">
    <div class="level2"></div>
    <div class="level2"></div>
  </div>
</div>

Answer №2

If you enjoy using grid layouts, setting up a simple grid with two columns and two rows is quite straightforward.

Check out this CodePen link for a visual representation of how the grid structure works. Pay attention to the CSS attributes related to the grid itself.

.container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  height: 50vh;
}

.container>div {
  display: flex;
  justify-content: center;
  align-items: center;
}

.image-slider {
  background: magenta;
  grid-column: span 2;
}

.page-link-1 {
  background: red;
}

.page-link-2 {
  background: green
}
<div class="container">
  <div class="image-slider">Image Slider</div>
  <div class="page-link-1">Page Link 1</div>
  <div class="page-link-2">Page Link 2</div>
</div>

View the example here: CodePen Example

Answer №3

My approach using flexbox:

body,
html {
  height: 100%;
}

.wrap {
  display: flex;
  height: 100%;
  flex-direction: column;
}

.slider {
  border: 2px solid red;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bottom-wrap {
  display: flex;
  flex: 1;
}

.link {
  border: 2px solid red;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
<div class="wrap">
  <div class="slider">Image slider</div>
  <div class="bottom-wrap">
    <div class="link">Page Link</div>
    <div class="link">Page Link</div>
  </div>
</div>

See the code in action on CodePen

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Changing a variable with Functions and Objects

I'm curious to know what the index variable returns in this code snippet. I believe it will be 0. function jsTest() { var index = 0; var counter = 0; var obj = {}; obj.index = index; var func = function () { for (index ...

The player clicks once and the game is played two times

Struggling with a coding issue here. I've got some code where you click on an image and if it can be moved to the next cell, it should move. function changecell(a){ var moved=false; if(a%3 !=0) { if(ij[a-1]==0) { moved=true; ...

What could be causing the HTML and CSS to not show the background image?

Hey, I'm new to html and css and I'm having trouble getting a background image to show up on my website. All I see is "first website" in the corner but the image isn't displaying. Here's the code I have: * { margin: 0; padding: 0 ...

How can I save files to the ~/Documents directory using Node.js on my Mac computer?

Trying to work with the user's Documents folder in Node.js on macOS: var logger = fs.createWriteStream('~/Documents/somefolderwhichexists/'+title+'.txt'); Encountering an error without clear cause. Error message received: Unca ...

Using a button click to toggle the vue-ctk-date-time-picker in VueJS

Currently, I am utilizing the Vue component - https://github.com/chronotruck/vue-ctk-date-time-picker within my own component. However, I am encountering an issue where I would like to maintain the component's original functionality while having a but ...

When trying to run the "npm start" command, I encountered a syntax error that specifically mentioned the use of

Every time I attempt to run the npm start command, I encounter the following error: I have followed the steps provided in this link: https://github.com/kriasoft/react-starter-kit/blob/master/docs/getting-started.md Could you please advise on how to resolve ...

What is the best way to empty the input field after a download event is completed in Node.JS?

For hours on end, I've been struggling with a persistent issue in my video downloader app. After successfully downloading a video, the input field where the URL is entered remains filled instead of clearing out. The screenshot below illustrates the p ...

Displaying the Polymer Paper spinner when the page is still loading

How can I make the polymer paper spinner display while the body tag is set to unresolved? I'm experiencing a brief blank screen before the page finishes loading. I'm feeling lost and unsure of how to begin. Check out the Polymer Project documen ...

Tips for emphasizing a searched item in V-data-table using VueJS

Is it possible to highlight a specific value in a v-data-table by searching for a particular word? Below is a snippet of my current code: EDIT: I am using the CRUD-Actions Example from the official Vuetify documentation. https://vuetifyjs.com/en/componen ...

Struggling to retrieve the value from ng-model?

Currently, I am utilizing this account due to being logged into Facebook on my other account and not having access to my phone for the verification code process. On another note, I am struggling to retrieve the value from an ng-model despite numerous atte ...

Display a list of items using ReactJS by mapping through an array of objects and rendering based on

How can I render a set of <div> </div> based on the items in an object without having to specify their names? In the code snippet below, I want the display of WorkObjectID and WorkObjectVal to be dynamic rather than static. If I include TempOb ...

The function is limited to a single use

Whenever I click on the blue color, my function works just fine. However, once I try to change it back to black, it stops working altogether. What could be causing this issue? Is there a simpler way to achieve the desired functionality? I have confidence ...

Ensure the validation of the form using jQuery and then proceed with submitting the form

My markupcode is structured as follows: <div> <form action="http://fileaction.com"> <label for="email">Email:</label> <input type="text" name="email" id="login-email" class=""> <label for="password">Passwo ...

Tips for extracting parameters from a JSON String using JavaScript

When attempting to parse a JSON String, I am encountering an issue where the parsed value is coming up as undefined. You can view the code on this jsfiddle link. <input type="submit" onclick=testJSON() value="Test"/> <div i ...

A gojs swim lane diagram requires a date axis to provide accurate time representation

I am currently working on a web application that requires a vertical swim lane activity diagram with a customized date axis displayed alongside it. The nodes in the diagram should be positioned based on their date attribute, and users should have the abili ...

Encountering an issue when trying to use SVG clip-path in Safari

I'm currently experimenting with creating a unique hexagonal border around a button. My approach involves enlarging the container element by a few pixels compared to the button size and using the same clip-mask on both elements to achieve a bordered e ...

"Utilizing JQuery to enhance task management by implementing a delete function

I need help figuring out how to create a function that can delete tasks from my todo list. Currently, each task has its own remove button, but I want to implement a single remove button at the bottom that removes checked or crossed out tasks. Any suggestio ...

Implementing a function to save a file to a nested directory in node.js

Currently, I'm utilizing node and express with the following directory structure: public img css js server.js Within server.js, I have the code snippet below for writing to a png file: fs.writeFile('testfile.png', imageData, func ...

Transfer information from the server to the client using NodeJS and Express

I am encountering an issue with sending data from my express server to the client side. I have implemented app.post and app.get, however the problem is that the request needs to originate from the client side. My requirement is to send the data from the se ...

Can Vue-router be used to load screens into Tabs?

In my setup, I have a routes file with multiple routes configured such as localhost:8000/test and localhost:8000/test2. My objective is to create a final route like localhost:8000/tabs, where I can utilize a tab library like bootstrap or Vuetify to displa ...