Designing a unique diagonal layout with HTML and CSS

Hey there, I have a question about creating diagonal backgrounds in web design. I've seen websites like Udacity and one my friend is working on that feature diagonal shapes or designs in the background. I'm curious about how to achieve this effect. For example, take a look at the homepage of Udacity where they have a split background. I'm not focused on the gradient aspect, just wondering how to create the diagonal shape. Here's the link to Udacity's page for reference:

Answer №1

.hero--homepage::before {
    content: '';
    width: 100%;
    height: 300px;
    z-index: -1000;
    background: linear-gradient(160deg, #02CCBA 0%, #AA7ECD 100%);
    transform-origin: left bottom;
    position: absolute;
    top: 0;
    left: 0;
    -webkit-transform: skew(0deg, -15deg);
    -moz-transform: skew(0deg, -15deg);
    -ms-transform: skew(0deg, -15deg);
    -o-transform: skew(0deg, -15deg);
    transform: skew(0deg, -15deg);
}
<div class = "hero--homepage"></div>

Answer №2

Here is a solution that should do the trick:

.container {
  position: relative;
  background-color: #fff;
  width: 100%;
}

.background {
  position: absolute;
  content: '';
  width: 100vw;
  height: 400px;
  background-color: #000;
  transform-origin: left bottom;
  top: 0;
  left: 0;
  -webkit-transform: skew(0deg, -30deg);
  -moz-transform: skew(0deg, -30deg);
  -ms-transform: skew(0deg, -30deg);
  -o-transform: skew(0deg, -30deg);
  transform: skew(0deg, -30deg);
}
<div class="container">
  <div class="background"></div>
</div>

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

I successfully made a GET request using Postman, but encountered an issue when trying to do the same request through a

Currently, my objective is to send URL encoded parameters through a GET request using the fetch function. To achieve this, I am attempting to display the parameters via Express in the following manner: app.get('/api', function (req, res) { c ...

Compatibility of Blackberry Webworks

As I prepare to build a Webworks app, the documentation indicates that it is designed to function only on devices equipped with OS 5.0 or later. However, I am curious if there exists a way to make the app compatible with devices running an OS version lower ...

Using Vaadin: update Label text with TextField input after Button is clicked

I'm working on a simple Vaadin form where I want the text entered in a TextField to appear in a Label after the user clicks on a Button. Here's the code snippet: package com.example; import javax.servlet.annotation.WebServlet; import com.vaad ...

When incorporating CSS with Bootstrap, it may not always have a visible impact on the

As a newcomer to using Bootstrap, I recently created a webpage with Bootstrap3. However, I encountered an issue when trying to apply two classes to the same element, as the CSS was not being applied: Here is the HTML code snippet: <div class="col-md-4 ...

Achieving equal height and width for 2 divs through Bootstrap/CSS techniques

I'm attempting to ensure that these two divs within a table have the same height and width using the following code: <div class="container"> {{#if orders}} <div class="filter"> <ul class="nav nav ...

Endpoint returns 404 status code when receiving a POST request, but returns 200 status code when

I recently developed a Node application using Express to create an API. When I send a GET request to the endpoint, everything functions smoothly and I receive a status of 200. However, upon sending a POST request to the same endpoint, I am greeted with a 4 ...

"Maximizing the functionality of HTML forms by incorporating PHP for efficient data retrieval

I have been exploring different approaches but I'm struggling to get this to function correctly. As a beginner, I am using form elements with dropdown menus to receive user input and then send the data via email. Here is the HTML and PHP code: <fo ...

utilizing services across multiple controller files

Service - optionService.js controllers - app.js & welcomeCtrl.js & otherCtrl.js app.js var app = angular.module('mainapp', ['mainapp.welcome','optionServiceModule']); app.controller('mainappCtrl', functio ...

Implementing ordering and limiting of elements in NestJS TypeORM relations

I am new to typeorm and relationships. I am currently facing some challenges and feeling a bit confused. I have a question regarding sorting relations in typeorm by id or createdDate without explicitly mapping them and limiting the number of elements. Here ...

How to maximize efficiency by utilizing a single function to handle multiple properties in Angular

I have 2 distinct variables: $scope.totalPendingDisplayed = 15; $scope.totalResolvedDisplayed = 15; Each of these variables is connected to different elements using ng-repeat (used for limitTo) When the "Load More" button is clicked (ng-click="loadMore( ...

I attempted to set up a Discord bot using JavaScript on Replit, but unfortunately, it seems to only respond when I mention the bot specifically, rather than to any regular

I've successfully created a python discord bot, but I'm encountering issues with the javascript one. Despite trying various solutions from StackOverflow, I'm unable to understand how to get it working. The plethora of online solutions for d ...

Getting access to props within a child component's mounting phase

It is commonly understood that when the child component is mounted before the parent component, trying to access props in the child component's mounted period will result in null. However, I recently came across a scenario where props were successful ...

Issues with Angular toggle sorting functionality not functioning as expected

$scope.searchObject = { from: 0, hydrate: false, size: 12, sort: 'timestamp:desc' }; $scope.sort = function(a) { var ascend = a + ':' + 'asc'; var descend = a + ':' + 'desc'; if ($scope.searc ...

What is the best way to inline center two block buttons using CSS?

Having difficulty centering two block buttons using inline CSS in the Darkly theme from Bootstrap. I am unable to directly edit the CSS and can only utilize inline CSS due to using the CDN version of the theme. <a href='/start'><button c ...

Leveraging JS Variables within Twig Template

I am trying to incorporate a JavaScript variable into Twig. Despite attempting to implement the solution mentioned here, my code below does not render the map properly. If I remove the part between "var polylineCoordinates" and "polyline.setMap(map);", th ...

Comparison of instancing, bufferGeometry, and interleavedBuffer in rendering techniques

I have a requirement to create numerous points and lines with position, size, and color attributes, and their positions are dynamic as they can be interactively dragged. Up until now, I have been using buffer Geometry, but recently I came across two other ...

Can elements be eliminated from a div based on their order?

https://i.sstatic.net/XIUnsMRc.png Hello everyone, I am currently attempting to replicate this design using ReactJS, but I am facing challenges in getting my code to function as desired. The issue lies in positioning the profile picture next to the searc ...

Deciphering arrays from javascript with PHP

I'm struggling to understand how to transfer a JS array into PHP. The data I have to work with is structured like this: var arrLow = [ { "e": "495864", "rank": "8678591", "rankmove": "<p><img src='up.php?uStyle=144'> UP 495864" ...

The jQuery animation is triggered within the hover() function, but it only runs on the

I am attempting to use jQuery to create a hover effect that changes the height of an element. When hovering, a .hover class is added, and when clicking, a .expanded class is toggled. The animation works correctly after the first time, but on the initial h ...

What is the method for adjusting the border color of an ng-select component to red?

I am having an issue with the select component in my Angular HTML template. It is currently displaying in grey color, but I would like it to have a red border instead. I have tried using custom CSS, but I haven't been able to achieve the desired resul ...