Tips for creating slanted div borders

I am working on a project where I have 4 divs serving as background colors. I want to create slanted bottom borders similar to the design in this image:

Below is the code I currently have:

<html>
<head>
<style>
html, body { height: 200%; padding: 0; margin: 0; }

#first {
top: 0;
background-color: orange;
height: 50%;
}

#second {
bottom: 0;
background-color: green;
height: 50%;
}

#third {
top: 0;
background-color: blue;
height: 50%;
}

#fourth {
bottom: 0;
background-color: red;
height: 50%;
}
</style>
</head>
<body>
<div id="first">&nbsp;</div>
<div id="second">&nbsp;</div>
<div id="third">&nbsp;</div>
<div id="fourth">&nbsp;</div>
</body>
</html>

Answer №1

For a well-structured grid layout, consider using resources like Foundation or Bootstrap. A sample setup could be:

<div class="row" id="firstBackground">
    <!-- Add your content here -->
</div>

<div class="row" id="secondBackground">
    <!-- Add your content here -->
</div>

<div class="row" id="thirdBackground">
    <!-- Add your content here -->
</div>

<div class="row" id="forthBackground">
    <!-- Add your content here -->
</div>

This layout structure should be helpful for your design needs.

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

A guide on dynamically accessing an image from the src directory using props in a Vite + React application

export default function Card(props) { return ( <card> <img className={cardCss.card__img} src={`../assets/imgs/card/${props.img}`} alt="" /> <div className={cardCss.card__stats}> ...

Utilize ng-repeat to iterate over two arrays

Two arrays are at my disposal here. The first array contains option content, while the second array consists of option tags (i.e., A, B, C, D). How can I structure the layout for the 'input type="radio"' using ng-repeat? To start off, I am attem ...

Creating a responsive table layout with CSS

I currently have the following code: .fiftyFiftySection { background-color: #000; } .odometer { font-size: 3em; text-align: center; } table td { column-width: 1000px; text-align: center; } @media (max-width: 500px) { table td { column ...

Positioning an anchor element over an image in Internet Explorer (IE)

Encountering an issue with IE9 (and 8) involving the positioning of empty anchor elements over an image. The anchors contain text, which is pushed off the page using CSS's text-indent property. Currently working on a website with promo panels display ...

Guide to customizing WordPress header menu buttons with CSS, excluding a specific button

I need help with custom CSS for my WordPress site. I want to apply a hover effect to all menu buttons except for the "Contact" button, which already has its own styling. The CSS code adds a growing line beneath the hovered menu item and a static line unde ...

Customizing the React Bootstrap Button by adding a unique icon and button label

Looking for a way to dynamically adjust button height based on the button name length? https://i.sstatic.net/156kO.png The current issue is that the button names are getting cropped. Here's what has been achieved so far: index.css .btn-product { ...

Enhance your horizontal stacked bar chart in chart.js by incorporating inner labels with the help of the 'chartjs-plugin-labels' plugin

Currently, I have integrated a package that allows me to incorporate labels into my charts - import * as pluginDataLabels from "chartjs-plugin-labels"; While it works perfectly fine with line charts, pie charts, and normal bar charts, I am facin ...

leveraging Excel input for data manipulation in Java

I am looking to create a code that will help me generate a line of flight using data from an Excel spreadsheet. The process involves calculating the time between flights, ensuring the plane has enough time on the ground before taking off again, and determi ...

Ensure that the child iframe is referencing its own content, and not that of the parent iframe

What I have is a nested Iframe setup as shown below <iframe id="is Static"> stuff <iframe id="Is Dynmic> <html>...</html> <body id="This is thebody"> other stuff </body> I am trying to listen for the mou ...

Unusual occurrences observed with the table

While working with tables, I've noticed an unusual effect. Take a look at the two fiddles below. http://jsfiddle.net/v5co5uy7/ (why are the cells in the left column pushed down?) http://jsfiddle.net/v5co5uy7/1/ (the cells in the left column are posi ...

When a CSS fluid layout includes a containing div with margin or padding, it may lead to

On my jsfiddle , the outermost wrapper div has a width of 100%. I am trying to create an inner div (tb_margin or tb_padding) where the content starts 40px from the left. I have attempted to use both margin and padding for this left spacing, but in both cas ...

Overlay Image on Card, Overflowing into Card Body

I currently have a webpage featuring cards. Each card includes a thumbnail at the top with an overlay. The main content of the card needs to be positioned outside of the overlay, but it ends up overflowing onto it. Take a look at the demo: https://codepe ...

navigation bar icons alignment problem

Help with positioning an icon next to the navbar text Example Code: <ul> <li><a href="#" id="other-color" class="ui-btn ui-shadow ui-btn-icon-left ui-custom-icon ui-arrow ui-nodisc-icon">Set Filter</a></li> <li> ...

What is the best way to adjust the size of a form element to be 600px wide only when the window width exceeds 600px?

As part of the application process for a coding bootcamp, I have been asked to complete an HTML/CSS assessment. After submitting my code, I received feedback stating that there was no 'form' element set to 600px when the window width exceeded 600 ...

sequential organization paired with double-column format

Looking for a CSS-only method to arrange an ordered list (ol) into two columns if it exceeds the height of its container. The number of items in the list can vary, and so can the height of the container. When attempting to set li with properties like widt ...

Create a stylish accordion in asp.net with custom arrow buttons using CSS

Can anyone help me find the proper CSS for an asp.net ajax accordion menu with a vertical orientation that includes arrow buttons on each pane? I need the arrows to change when the menu is expanded versus collapsed. ...

What is the best way to horizontally center a div that has position:absolute within a table

Hello there, I am attempting to align a div in the center of a td element. I have set the position of the td as relative and the div as absolute. Is there a way to center the div without changing its absolute positioning? ...

How big is the array size in the WebAudio API data?

Exploring the visualization of waveform and FFT generated by the audio stream from the microphone through the WebAudio API. Curiosity strikes - what is the size of each data array available at a given moment? Delving into the getByteTimeDomainData, it men ...

Switch to light mode upon clicking the toggle?

On the top left corner of this page, there's a toggle for "Light/Dark mode". Clicking on 'Light mode' smoothly transitions to dark mode without any issues. However, once it's in Dark mode and you try to switch back to 'light mode&a ...

Adding a pair of labelled angled columns in a container that spans the full width is a breeze

I'm in pursuit of this: https://i.sstatic.net/HYbC1.jpg What I currently possess is: <div class="row slantrow"> <div class="row slant-inner"> <div class="col-md-6 slant-left"> <p>text</p> ...