Adjust the CSS border to finish at a 90-degree angle rather than a 45-degree angle

The div I'm working with has unique colors for the border-bottom and border-right properties, creating a diagonal line that separates the box at a 45 degree angle.

I'm looking to adjust the bottom-border to be shorter in order for the right border to extend all the way down to the bottom of the element, resulting in a 90 degree angle separator line. How can I achieve this?

Answer №1

You have the ability to achieve this effect using the box-shadow property.

Check out this live demo: http://jsfiddle.net/UniqueCoder/DemoExample/

Desired Result:

Styling with CSS:

#custom-design {
    border-left: 10px solid blue;  
    box-shadow: -15px 5px 0 0 orange;
    height: 100px;
    margin: 20px;
    width: 100px;
}

Related HTML Code:

<div id="custom-design"></div>

Answer №2

To resolve the issue, I successfully utilized the CSS property border-width. By adjusting the border width on specific edges, I was able to hide unwanted borders.

For example, if we wish to eliminate the border on the top edge, setting border-width to 0 achieves this effect.

border-width: 0px 5px 5px 5px;
border-color:#ddd #000 #000 #000;

Answer №3

Interesting fact: Border corners are always mitered, which may not be noticeable unless different colors are used.

To create a butt joint effect, you can stack two divs on top of each other to achieve the desired result:

div {
  position: absolute;
  left: 0;
  top: 0;
  height: 100px;
  width: 100px;
}
<div style="border-left: 2px solid #ff0000; border-bottom: 2px solid #ff0000;">
</div>
<div style="border-right: 2px solid #00ff00; border-top: 2px solid #00ff00;">
</div>

For more control over the appearance of the joint, you can stack additional divs or manipulate the top and bottom borders differently.

Answer №4

To create a stylish border effect for both the top and bottom of your box, consider using the box-shadow property:

.custom-box {
border: 10px solid #ddd;
border-top: 0;
border-bottom: 0;
box-shadow: 0 10px 0 #2E8B57, 0px -10px 0 #2E8B57;
float: left;
width: 100px;
height: 100px;
}
<div class="custom-box"></div>

Answer №5

What you are witnessing is the diagonal splitting of borders on different sides around the corner:

.border {
  border: 10px solid;
  border-top-color: forestgreen;
  border-right-color: gold;
  border-bottom-color: steelblue;
  border-left-color: firebrick;
  width: 40px;
  height: 40px;
}
<div class="border"></div>

This phenomenon is commonly utilized in creating CSS triangles

To address this issue, two solutions can be implemented: utilizing borders on a wrapper element or using linear gradients:

Option 1: Wrapper Elements

.wrapper {
  border-bottom: 10px solid steelblue;
  height: 40px;
  width: 50px;
}

.border {
  border-right:10px solid gold;
  height: 40px;
  width: 40px;
}
<div class="wrapper">
  <div class="border"></div>
</div>

It is crucial to note that the wrapper element must have a height 5px greater than its child for proper alignment of the borders.

Option 2: Linear Gradients

.border {
  border-bottom: 10px solid;
  border-right: 10px solid;
  border-image: linear-gradient(to top, steelblue, steelblue 10px, gold 5px, gold) 10;
  height: 40px;
  width: 40px;
}
<div class="border"></div>

Answer №6

If you want sharp edges on your borders, try setting two of them to 0px and then activating a basic animation like this:

    @keyframes widthSet {
        to{
            border-right-width: 10px; //or top and bottom, it's up to you
            border-left-width: 10px;
        }
    }

and don't forget to add animation-fill-mode: forwards;

Answer №7

It's not possible.

If you need a right angle of 90˚, you can simply utilize colored divs.

To achieve a similar outcome for various angles, consider utilizing skew transitions and absolute positioning. However, it may prove challenging (if not unattainable) to replicate the same appearance in older browsers, particularly IE8 and below.

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

Issue encountered when attempting to select a button with selenium

I'm attempting to use Selenium to click on a button, but encountering an error in the process. The specific error message is shown below: https://i.stack.imgur.com/NQjnh.png This snippet of code represents the accessed HTML page: https://i.stack.i ...

Adjusting the content of a single text box by typing in another

Is it feasible to automatically convert a Nepali date input in one textbox into an English date and display it in another textbox without any page refresh? I have a PHP function that can translate dates between Nepali and English, and I want it to execute ...

Setting up Angular Toolkit via npm installation

After successfully installing the UIKit npm package within an Angular 2 CLI project, what steps should I take to utilize it? I have also installed typings for UIKit (@types/uikit), but I am unsure of how to properly import the package into a controller i ...

Create dynamic and interactive content by embedding text within SVG shapes using the powerful D

How can I write text into an SVG shape created with d3.js and limit it to stay inside the shape similar to this example http://bl.ocks.org/mbostock/4063582? I attempted to use a clipPath following the example provided. However, when inspecting with firebu ...

Leveraging JavaScript to trigger onClick() functions for multiple buttons throughout a webpage

        While searching for solutions, I came across several articles with similar topics, but unfortunately, none of the proposed solutions worked. Please forgive me if it was due to my own error. Background I am assisting a client who is transition ...

What is the method for adjusting the subheader color on a Material UI card component?

How can I change the subheader text color to white in a Material UI Card with a dark background? Here is my code: const useStyles = makeStyles(theme => ({ menuColor: { backgroundColor: theme.palette.primary.main, color: '#ffffff', ...

What is the best way to create stylish corners on my website?

I'm struggling with creating a corner like the one shown in the image. As a beginner in frontend development, I attempted to write the following code but now I'm stuck. The Snippet: * { margin: 0; padding: 0; } body { height: 100vh; ...

Incorporate a division based on the selection made from a jQuery dropdown menu

Is there a way to dynamically display a div to the right of a drop-down menu based on the user's selection using DOM manipulation? For reference, you can view an example of my current progress here: http://jsbin.com/#/afojid/1/edit The initial drop ...

Creating a personalized v-for loop with v-if to apply a specific class to a div element

How can I correctly utilize v-if when using v-for inside? I am aiming to implement a condition where if the index is 0 or it's the first data, then add an active class. <div class="item active" v-for="(item, key, index) in slideItem" :key="item._ ...

What is the best way to display the time of a post update similar to the style of

I am currently working on creating a notification deck. Instead of displaying the time when a notification was received, I aim to show the time that has passed since its arrival similar to how Twitter and Facebook do it with formats like "32m" or "1 hour a ...

Hover Effects on Facebook Tabs

I am currently facing an issue with implementing CSS-sprite for image-based rollovers within a Facebook Tab page. Strangely, the background images are getting removed by Facebook only when inside a Tab page and not in the main application itself. It seems ...

Changing from a vertical to horizontal menu as the parent div is resized

I am looking for a solution to create a CSS effect or Javascript code that will hide a menu inside a div when the browser window or parent div is resized. I want to display another div with the same menu in horizontal orientation when the first one is hidd ...

Using Chrome in Application Mode with Shortcuts Disabled

When trying to utilize Chrome in application mode as a host for an HTML5 application, it becomes evident that there are significant limitations. For instance, pressing CTRL+T launches a new Chrome browser window, allowing the user to input text into the a ...

Is there a way to use flexbox in a grid to center only a specific tab from MUI?

I am working with an array of tabs and encountering a layout issue. The tabs need to share the available space when there's more than one tab, but when there's only one tab, it should be positioned in the middle of the column. How can I address t ...

What is the best way to delete previously entered characters in the "confirm password" field after editing the password

Is there a way to automatically remove characters in the confirm password field if characters are removed from the password field? Currently, when characters are entered into the password field, characters can also be entered into the confirm password fiel ...

How can I resolve the issue of a lengthy link spanning two lines in Internet Explorer, while displaying correctly in other browsers on a Bootstrap navigation

Currently in the process of developing a responsive website with Bootstrap. The navigation buttons at the top are displaying correctly in Chrome, Safari, and Firefox, but in IE, the button labeled "Public Consultation" is wrapping onto two lines. I suspec ...

How to retrieve an element in jQuery without using the onclick event listener

I'm looking to extract the element id or data attribute of an HTML input element without using the onclick event handler. Here is the code I currently have: <button class="button primary" type="button" onclick="add_poll_answers(30)">Submit</ ...

Utilize CSS to incorporate special characters as list markers

Is there a way to use CSS to make the list marker in an HTML list display as "►"? ...

Arrange various Div elements of varying sizes in a predetermined sequence

I need to ensure that a large div maintains the same height as 20 other divs within the same container, when the screen size is between 1024px and 1920px in width. The challenge lies in arranging all these items in a floated layout grid that looks clean a ...

Graphs vanish when they are displayed in concealed sections

Looking for a way to toggle between two charts (created with charts.js) by clicking a button? Initially, I had them in separate divs, one hidden and the other visible: <div id="one"> <canvas id="myChart1" width="400" height="400"></can ...