Dividing the background horizontally into two sections with contrasting colors

Is it possible to achieve a background image like this using CSS?

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

Answer №1

To create a gradient effect, you can utilize the linear-gradient() CSS function:

.container {
  background: linear-gradient(265deg, #ff4c5d 40%, #3487ec 60%);
  border-radius: 6px;
  height: 250px;
  width: 180px;
}
<div class="container"></div>

Answer №2

Yes, there is a way to achieve this effect using pseudo-classes such as :before and :after.

div {
  width: 150px;
  height: 200px;
  background: #41c7b4;
  position: relative;
  overflow: hidden;
  border-radius: 5px;
}

div:before {
  content: "";
  display: block;
  width: 200px;
  height: 100px;
  position: absolute;
  bottom: 0;
  left: -25px;
  transform: rotate(-10deg);
  transform-origin: top right;
  background: #ff7c4a;
}
<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

Obtaining the HTML content of a div element that has been retrieved through an AJAX request to a PHP script

My challenge is to fetch a dropdown menu from a server and then manipulate it using jQuery after loading. Although everything loads correctly, I am unable to interact with the dropdown items because they were dynamically added post AJAX response instead of ...

retrieve information from a div using an AJAX request

I don't have much experience with ajax and javascript, but I need some assistance, so I will do my best to explain clearly! Below is the JavaScript associated with a button: $('#button-confirm').on('click', function() { $.ajax({ ...

Hovering over the Jquery menu will display only the first child element

Hey there, newbie here looking to learn some new things. I ran into an issue where only the first child of the menu shows up when hovering over the parent element. Can anyone help me out with this problem? Please ignore the css for now. Any assistance woul ...

When anchor links (href) are incorporated within a flex layout and flex-direction is set to row, they may not function as

I've designed a website with three horizontal pages, each filling the entire screen. There's a fixed menu with links that scroll to specific pages when clicked. However, users can also scroll horizontally to navigate between screens. If two page ...

Is there a way I can create a slight gap between the icon and the text in this area?

After learning Reactjs and JavaScript, I have encountered a problem that I need advice on. In the image provided, the "Sign in" text does not have proper spacing between the icon and the text, unlike the other menu items. https://i.stack.imgur.com/b663b. ...

Avoid constantly destroying the Bootstrap Popover

I am facing a challenge with retrieving data from two checkbox inputs inside a popover. The issue arises because the popover appears in the DOM when I click a button, but is removed when I click it again. It seems that the problem lies in the fact that Jav ...

use bootstrap to align text vertically according to the image

I am trying to figure out how to center a text vertically next to an image. While I know how to align text horizontally using text-center in bootstrap, I am unsure about how to align it vertically. Is there a way to accomplish this using bootstrap? < ...

Turn your mouse cursor into a dynamic and animated image using jQuery

I've implemented a code snippet that replaces the cursor with 2 images placed at a small distance from each other: $(document).mousemove(function (e) { $("#firstImage").css({ left: e.pageX, top: e.pageY }); ...

What is the best way to isolate the CSS of individual components in Angular 2?

For the first component: CSS-- ngx-dnd-container { color:black; background-color: white; } HTML- <ngx-dnd-container [model]="targetItemsA" dropZone="multiple-target-a" </ngx-dnd-container> For the sec ...

The image tag disrupting the spacing between lines

Here's a snippet of the css and html code: CSS: div { height:24px; line-height:24px; } HTML: <div><img src="image.png"/>Text</div> According to the code, a div should be 24 pixels high with text vertically centered after ...

Large padding in the main container of Bootstrap 4

Hey there, this is my third and hopefully final question. I'm having some trouble with my page layout that was supposed to look like this initially: [navbar] [1][2][3] I was aiming to achieve the following effect when res ...

Combining jQuery with AngularJS for optimal web development outcomes?

As someone new to AngularJS, this project is challenging my knowledge of ng-repeat and controllers. Objective : My goal is to have the guitars appear when an option is selected from the drop-down menu and the button is clicked using ng-repeat. Currently, ...

What is the best way to showcase the outcome using the <table> tag in HTML with columns containing 50 records each, except for the final column?

I have developed a program that is currently creating 540 different numbers. My goal is to present these 540 distinct numbers in columns with 50 records each (except for the last column where there may be fewer than 50 records) using the HTML <table> ...

Manipulating vertices in Three.js

I am fairly new to Three.js and I am attempting to create a basic PlaneGeometry. The process would involve: The user will specify their preferred height and width for the PlaneGeometry The browser will then render the plane with the height and width ...

Display a list group in two columns using Bootstrap 4's grid system

Is there a way to create a list-group with 2 columns using bootstrap 4? <div class="categories"> <h4>Categories</h4> <ul class="list-group"> <li class="list-group-item active">Name 1</li> <li clas ...

Ways to extract variables from a component and utilize them in App.js

Despite my efforts to search online, I could not find the answer or understand what I needed to. My issue: I need the "inputVal" variable from the "InputField.js" component to be accessible in the "App.js" component (specifically in the fetch request where ...

Tips for successfully sending data to an ng-include controller

So, I've got this ng-include html element, and I'm trying to figure out how to pass data from an external source to the controller. The primary controller is responsible for fetching json data from a http webservice, and then parsing that data i ...

Tips for integrating semantic HTML with React components

As a newcomer to react, I am eager to establish a strong foundation before delving deep into the language and risking having to backtrack later on. I am curious about how to incorporate semantic HTML in react. Elements such as <header>, <nav>, ...

Implementing class changes based on scroll events in JavaScript

const scrollList = document.getElementsByClassName('scrollList'); function scrollLeft() { scrollList.scrollLeft -= 50 } function scrollRight() { scrollList.scrollLeft += 50 } #scrollList { display: flex; overflow: auto; width: 10 ...

Utilize xdebug and NetBeans 8.2 to troubleshoot PHP code submitted through an HTML form

After successfully setting up the XDebug extension to debug PHP code within NetBeans IDE (ver. 8.2), I encountered an issue. While debugging works fine when setting a breakpoint and running the script in debug mode, I am having trouble debugging PHP code t ...