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

https://i.sstatic.net/A1eUh.png

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

Having trouble with the Vuejs validation code not functioning correctly?

I need help with a JavaScript function that posts objects to the backend only if all items are numbers. Here is the code snippet I'm working with: var MyApp = new Vue({ el: '#my_element', data: { errors: [], ...

Responsive Div that Resizes Proportionally within Parent Container

Having a div element that adjusts its height based on width to maintain aspect ratio, I aim to place this div within another while maximizing available space vertically and horizontally without any cropping. It seems that object-fit: contain, typically use ...

A Promise-based value returned by a Typescript decorator with universal methods

I am currently working on creating a method decorator that can be applied to both prototype and instance methods. Referenced from: Typescript decorators not working with arrow functions In the code provided below, the instanceMethod() is returning a Prom ...

Is it possible to design a Controller and View that can manage the creation of one-to-many objects, specifically a single "container" object along with an unlimited number of "content"

One of the functionalities for users on the website will be the ability to create documents made up of chapters in a one-to-many relationship. Traditionally, this would involve creating separate views for chapter and document creation. How can I develop ...

Why does the React input value keep its value when the modal is re-rendered, despite the state being updated correctly?

Take a look at this sandbox link for the code snippet: Sandbox Showcased below is a table structure: https://i.sstatic.net/3F3Mc.png By clicking on the 'edit' button, a modal window opens up as shown below allowing you to edit input fields (onC ...

Analyzing and refreshing the data entries in firebase database

https://i.stack.imgur.com/ZMjck.png I have been attempting to modify my Username password group name. However, the update process is not successful. I am looking for a way to compare data before updating fields, but I am unable to find a suitable method. ...

Retrieving Firestore information as a JavaScript object

I'm working on retrieving data from Google Firestore as a JavaScript object in Vue.js (3). It functions correctly when used within a V-for loop, but I also need to utilize the array in methods. How can I convert the Firestore data into a basic JavaScr ...

Displaying TestNG Reporter information in Gradle-generated HTML test reports

I've been searching high and low for a solution to my problem with no luck, so I'm turning directly to you. Is there any way to display TestNG's Reporter output in Gradle HTML reports? Here's the scenario: I have multiple testNG test m ...

Switching out the background image with a higher resolution one specifically for users with retina devices

I'm trying to create my very first website that is retina ready, but I've run into an issue when it comes to updating images to higher resolutions in CSS. I'm unsure how to go about having a standard image as the background and then switchin ...

Error: When attempting to utilize the Image-Slider, an issue arises with reading the property 'classList' which is undefined

I am currently in the process of developing a website using Strapi as my CMS and Next.js(React) for the frontend. The website features an image slider that includes images, headlines, and descriptions. However, I have encountered an issue where after spen ...

Table design with fixed left columns and header that adjust to different screen sizes

After reading various articles on this issue, I have been unable to find a solution. Most of the examples I've come across feature tables with a single row for the header and rows that consist of just one row, similar to a calendar. My table, on the o ...

Use flexbox to manage the width of containers and control the wrapping of elements

Hello, I am a newcomer to utilizing flexbox in CSS. I have these "boxes" that need to maintain their width and wrap when the screen size is small. On a large screen: https://i.sstatic.net/dXnGC.png On a small screen: https://i.sstatic.net/8rZso.pn ...

Position text input boxes on the right side of the div element

I am seeking help with aligning the text inputs to the edge of .formColumn2 so they appear in a neat line together. I have attempted using margin-right:0 and margin-left, but these solutions end up extending the .formColumn2 div which is not my desired out ...

Transferring data between functional components in ReactJS and dealing with the output of [object Object] or undefined

I'm struggling with passing a prop in functional components that are both located in the same .js file. I previously attempted to seek help for this issue, but unfortunately, it wasn't productive. My goal is to extract the member_id from the GET ...

"Revamping the text style of input materials in React JS: A step-by

How can I modify the style of the text field component in Material UI? Specifically, I would like to change the appearance of the text that the user enters. I have attempted to use the Material API, but it has not provided the desired results. Here is an ...

Cutting an image in ReactJS using the HTML5 canvas feature

Seeking a way to crop images in reactjs without relying on any external library. The goal is for users to upload an image and perform cropping using raw JavaScript, then replace the uploaded image. How can this be achieved without the use of libraries? Loo ...

What is the best way to eliminate the border around an image when including a hyperlink?

There seems to be a rectangle showing up outside the link that I would like to remove. How can I get rid of it? No Image <a href="~/Web Pages/Home.aspx" runat="server"> <img src="<%= ResolveUrl("~/Images/TestToday.png") %>" alt="No im ...

A guide on displaying a text file from a URL in a reactjs application

When utilizing the code provided below, I have successfully managed to display the content of a local text file on a webpage. However, when attempting to render a text file from a URL, the state becomes null resulting in an empty display. In order to ren ...

Is it common for Google Chrome console snapshots to have a prolonged idle time?

I noticed in Google Chrome console snapshot that my JavaScript code has a long "Idle" time. I'm not sure if this is normal. Attached is a screenshot for reference: https://i.stack.imgur.com/k0mkp.png Could this extended "Idle" time be attributed to ...

How can I retrieve a file from the www-directory using PhoneGap?

Despite trying various solutions to access a file in the www folder, none seem to work for me. I am testing the application on iOS with the iOS simulator. The specific file I want to access is test.txt located in the www folder. Here is my current appr ...