Перекрытие границ невозможно ...
... но вот решение для создания вашего эффекта только с помощью CSS, используя:
- Несколько
linear-gradient
s для созданияbackground
background-blend-mode
для смешивания цветов в углах
⋅ ⋅ ⋅
Обновлен фрагмент:
Использование фонового синтаксиса, как здесь сделал Темани https://stackoverflow.com/a/50526694/5061000
.boxed {
position: absolute;
margin: 5pc auto; /* Modified to better fit in tiny snippet */
--border-pc: 10%; /* You could even use a CSS variable to store the width if you want to be able to modify it easily. Or the colors. Or both. */
background:
/* Shorthand syntax used below: image position/sizeX sizeY */
linear-gradient(rgba(229, 099, 057, 1), rgba(229, 099, 057, 1)) top /100% var(--border-pc), /* Orange with CSS var */
linear-gradient(rgba(000, 171, 238, 1), rgba(000, 171, 238, 1)) bottom/100% var(--border-pc), /* Blue */
linear-gradient(rgba(127, 203, 170, 1), rgba(127, 203, 170, 1)) left /var(--border-pc) 100%, /* Green */
linear-gradient(rgba(186, 179, 173, 1), rgba(186, 179, 173, 1)) right /var(--border-pc) 100%; /* Gray */
background-blend-mode: multiply;
background-repeat: no-repeat;
height: 20pc;
width: 20pc;
top: 0;
right: 0;
bottom: 0;
left: 0;
transform: rotate(45deg);
}
<section class="boxed">
<!-- <p>This will contain the box properly</p> -->
</section>
⋅ ⋅ ⋅
Фрагмент старого стиля:
Да, это работает, но япредпочитаю первый!
.boxed {
position: absolute;
margin: 5pc auto; /* Modified to better fit in tiny snippet */
--border-pc: 10%; /* You could even use a CSS variable to store the width if you want to be able to modify it easily. Or the colors. Or both. */
/* I tried to indent it to better see the code: */
background-image:
linear-gradient(to top, /* Blue */
rgba(0, 171, 238, 1) 0%,
rgba(0, 171, 238, 1) var(--border-pc), /* example use of the CSS var */
transparent var(--border-pc) ),
linear-gradient(to right, /* Green */
rgba(127, 203, 170, 1) 0%,
rgba(127, 203, 170, 1) 10%,
transparent 10% ),
linear-gradient(to bottom, /* Orange */
rgba(229, 99, 57, 1) 0%,
rgba(229, 99, 57, 1) 10%,
transparent 10% ),
linear-gradient(to left, /* Gray */
rgba(186, 179, 173, 1) 0%,
rgba(186, 179, 173, 1) 10%,
transparent 10% );
background-blend-mode: multiply; /* Added to mix the colors */
height: 20pc;
width: 20pc;
top: 0;
right: 0;
bottom: 0;
left: 0;
transform: rotate(45deg);
}
<section class="boxed">
<!-- <p>This will contain the box properly</p> -->
</section>
(Обратите внимание, что если вы не используете background-blend-mode
, вы можете выбрать, какие градиенты перекрывают другие, играя с их порядком!)
Надеюсь, это поможет.