Adding new divisions to an already existing division with angled borders

I am currently attempting to create a header similar to the one displayed in the attached image. Despite trying various solutions found on this platform, I have not been able to achieve the desired result. I have managed to work out the text and logo elements, but require assistance with creating the slanted div borders.

The specific effect I am aiming for is demonstrated in the following image:

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

Answer №1

Give this CSS snippet a shot:

header {
  border:1Px solid;
  height: 200px;
  position: relative;
}

header:before, header:after {
  position: absolute;
  width: 0;
  height: 0;
  content: '';
  border-width: 100px;
  border-style: solid;
}

header:before {
  left: 0;
  border-color: transparent transparent transparent #000;
}

header:after {
  right: 0;
  border-color:transparent #000 transparent transparent ;
}
<header></header>

Answer №2

If you want to enhance the appearance of your header, consider using triangles to create slanted borders;

header{
  width: 100%;
  height: 200px;
  background: #2c2d2e;
}

.triangle-right {
  width: 0; 
  height: 0; 
  border-top: 100px solid transparent;
  border-bottom: 100px solid transparent;
  position: absolute;
  left: 0;
  
  border-left: 200px solid white;
}

.triangle-left {
  width: 0; 
  height: 0; 
  border-top: 100px solid transparent;
  border-bottom: 100px solid transparent;
  
  border-right: 200px solid white;
  position: absolute;
  right: 0;
}
<header>
  <div class="triangle-left"></div>
  <div class="triangle-right"></div>
</header>

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

activating a jQuery function and sending a parameter

Looking for some help with JavaScript - I'm having trouble getting this code to work. I need to trigger a predefined function from one script within my AJAX script. Specifically, I want to activate the qtip functionality on the content of a div that i ...

Obtaining an element through its id using an expression in an Angular directive

Here's a complex question that needs to be broken down. I'm trying to mimic the behavior of the native <label> for <input>. Since nesting is not an option, I use a style like this: <input type="checkbox" id="test" /> Some other ...

Enable autocomplete feature in a PHP form once the user starts typing their name

After searching for similar questions, I couldn't find any with the same "variables," so here's my dilemma: I have a basic form where I input a name and I want the rest of the form to be filled in automatically (ID). Retrieving data from the da ...

Tips to ensure the div remains 100vh in height, even when empty

As I work on a simple webpage with a header, body, and footer, it's essential for me to ensure that the content takes up the entire height of the page using 100vh. However, if I only have plain text in the body section without any child tags, it ends ...

Encountering Datepicker Issue in Your Angularjs App?

I am currently working on a web application using Angular JS and I encountered an error when trying to incorporate a date picker. The error message displayed is "elem.datepicker is not a function" To implement the datepicker, I found reference code in thi ...

Update a BehaviourSubject's value using an Observable

Exploring options for improving this code: This is currently how I handle the observable data: this.observable$.pipe(take(1)).subscribe((observableValue) => { this.behaviourSubject$.next(observableValue); }); When I say improve, I mean finding a wa ...

Ways to integrate a security protocol with a graphql resolver

I'm currently diving into the world of graphql and I'm facing a challenge with incorporating an authentication/authorization system into my project. I stumbled upon an example on Medium, but I'm struggling to grasp how a guard connects with ...

Tips for maintaining grid width when columns are rearranged in the column menu

Is it possible to stop jqgrid from changing its width to full screen after column selection? I attempted the code below, following guidance from How to change column name in column chooser pop up in jqgrid? My aim was to create a column switcher function ...

The property 'push' cannot be read because it is undefined

$scope.AddTask = function () { $scope.tasks.push([{ "taskName": $scope.taskName, "priority": $scope.selectedP }]); }; $scope.tasks = [{ "taskId": 1, "taskName": "task 1", "priority": 1 }, { "taskId": 2, "taskName ...

What is the best way to retrieve the index of the chosen option from a select element in Angular when

My Angular application includes a simple <select> element using Material design: <mat-form-field> <mat-label>Type</mat-label> <mat-select placeholder="Type" formControlName="type" name="type" id="name"> <mat-option ...

What is the best way to set up the Bootstrap 4 popover in a React project?

Struggling with implementing popovers in my project, following the guidelines at: https://getbootstrap.com/docs/4.0/components/popovers/. The documentation mentions that popovers are a plugin and require the tooltip plugin as well. After making changes to ...

Utilize Twitter Bootstrap 4 to organize menu items in neat rows

I would like my menu to be structured in rows rather than wrapping and breaking to the next line when there is no more space. For instance: https://i.sstatic.net/dInTx.png Currently, it looks like this: https://i.sstatic.net/QkVS6.png Even changing to ...

The hover effect fails to function properly after altering the background color. The default color setting is transparent

<button class="button-main slide">Slide Left</button> .button-main{ color: black; outline: none; background: transparent; border: none; letter-spacing: 0.0625em; padding: 8px 10px; text-transform: uppercase; font: b ...

Ways to incorporate gentle page breaks into an HTML document

My task involves creating an XSL script to analyze various XML files that share a similar structure. The aim is to parse these XMLs and transform them into HTML pages. For longer XML documents, I want the resulting HTML page to be paginated (meaning the pa ...

Is there an optimal method for executing shell commands quickly in Node.js?

How can I efficiently run a large number of shell commands sequentially, for example 50 or 60 commands one after the other? For instance: const arr = ['/hello', '/temp', '/temp2', '/temp3', '/temp5', ...... ...

Unable to retrieve information from the wiki API

Here is the link to my codepen project: https://codepen.io/mlestina/pen/OZpOQW?editors=1111 I am having trouble retrieving data from the Wiki API. When I check the Contr-Shift-J readout, I see: Loading failed for the <script> with source “https: ...

Creating personalized validation for an AJAX popup in the MVC framework

In my MVC project, I am trying to implement AJAX popup with custom validation. I have created a CustomValidator class and overridden the IsValid() method. However, I am facing an issue where the custom validations are not rendering correctly within the pop ...

I am running into issues getting Tailwind CSS to work in my project. Despite following the installation instructions in the documentation and trying to learn this new CSS framework, it doesn't seem to

//I followed the instructions in the tailwind documentation to install and set up everything. However, when I try to use tailwind utility classes in my HTML file, they don't seem to work. Can someone please assist me with this issue? // Here is my sr ...

Tips for eliminating repetitive code in JavaScript

I have a jQuery function that deals with elements containing a prefix 'receive' in their class or ID names. Now, I need to duplicate this function for elements with the prefix 'send'. Currently, it looks like this: function onSelectAddr ...

How can recursion be implemented when the items are interdependent?

I am looking to create a function that can generate a list of individuals upon whom a specific person relies. The complexity here lies in the fact that these individuals may, in turn, rely on the original person. To illustrate: const people = { ' ...