How to divide circle into 2 parts, which can be rgb or url image? which looks like
so I wrote code which works just with rgb, but I don't know how it can be with url image... please help me:
.divided-circle {
width: 25px;
height: 25px;
background: linear-gradient( 135deg, #26A0DA 50%, #d92550 50%);
border-radius: 50%;
border: 0.5px solid #9b9b9b;
margin-right: 5px;
}
<div>
<div class="divided-circle"></div>
</div>
you can try like below:
.box {
width:150px;
border-radius:50%;
background:red; /* first background */
position:relative;
overflow:hidden;
}
.box::before {
content:"";
display:block;
padding-top:100%;
background:url(https://picsum.photos/id/1074/800/800) center/cover; /* second background */
/* adjust the below angle to control the rotation */
-webkit-mask:linear-gradient(60deg,#fff 49.8%,transparent 50%);
mask:linear-gradient(60deg,#fff 49.8%,transparent 50%);
}
<div class="box"></div>
With CSS variables to easily control:
.box {
--a:65deg; /* angle of rotation */
/* first background */
--b1:red;
/* second background */
--b2:url(https://picsum.photos/id/1074/800/800) center/cover;
width:150px;
display:inline-block;
border-radius:50%;
background:var(--b1);
position:relative;
overflow:hidden;
}
.box::before {
content:"";
display:block;
padding-top:100%;
background:var(--b2);
-webkit-mask:linear-gradient(var(--a),#fff 49.8%,transparent 50%);
mask:linear-gradient(var(--a),#fff 49.8%,transparent 50%);
}
<div class="box"></div>
<div class="box" style="--b1:blue;--b2:linear-gradient(red,yellow);--a:135deg;"></div>
<div class="box" style="--b1:url(https://picsum.photos/id/1014/800/800?grayscale) center/cover;--b2:url(https://picsum.photos/id/1014/800/800) center/cover;--a:180deg;"></div>
You can use clip-path for this:
.overlap1 {
position: absolute;
clip-path: polygon(0 0, 0% 100%, 100% 0);
}
.overlap2 {
position: absolute;
clip-path: polygon(100% 100%, 0% 100%, 100% 0);
}
<img class="overlap1" src="https://i.ya-webdesign.com/images/avatar-png-1.png"/>
<img class="overlap2" src="https://cdn.iconscout.com/icon/free/png-512/avatar-369-456321.png"/>
More on clip-path here.
You can border-radius this way, and inside the divs you can image or text ...
.divided-circle{
width: 150px;
height: 150px;
margin-right: 5px;
display: flex;
transform: rotate(45deg);
}
.divided-circle .left {
width: 50%;
height: 100%;
border-radius: 100% 0% 0% 100% / 50% 50% 50% 50%;
background: #cdcdcd;
border: 0.5px solid #9b9b9b;
border-right: none;
}
.divided-circle .right {
width: 50%;
height: 100%;
background: #212121;
border-radius: 0% 100% 100% 0% / 50% 50% 50% 50%;
border: 0.5px solid #9b9b9b;
border-left: none;
}
<div>
<div class="divided-circle">
<div class="left"></div>
<div class="right"></div>
</div>
</div>
Related
I have a circle progress bar, only with HTML and CSS, I used keyframes for loading (animation). But the loading is from right to left I wanna reverse it. I edit my CSS keyframes but nothing at all. I try also animation reverse again nothing.
Fiddle:
https://jsfiddle.net/d20wu8e4/
My Result (image):
https://ibb.co/0KCSsZY
What I want:
https://ibb.co/MGCpHqS
* {
box-sizing:border-box;
}
.progress {
width: 150px;
height: 150px;
background: none;
margin: 0 auto;
box-shadow: none;
position: relative;
}
.progress:after {
content: "";
width: 100%;
height: 100%;
border-radius: 50%;
border: 3px solid #fff;
position: absolute;
top: 0;
left: 0;
opacity: 0.5;
}
.progress>span {
width: 50%;
height: 100%;
overflow: hidden;
position: absolute;
top: 0;
z-index: 1;
}
.progress .progress-left {
left: 0;
}
.progress .progress-bar {
width: 100%;
height: 100%;
background: none;
border-width: 2px;
border-style: solid;
position: absolute;
top: 0;
}
.progress .progress-left .progress-bar {
left: 100%;
border-top-right-radius: 80px;
border-bottom-right-radius: 80px;
border-left: 0;
-webkit-transform-origin: center left;
transform-origin: center left;
}
.progress .progress-right {
right: 0;
}
.progress .progress-right .progress-bar {
left: -100%;
border-top-left-radius: 80px;
border-bottom-left-radius: 80px;
border-right: 0;
-webkit-transform-origin: center right;
transform-origin: center right;
animation: loading 1.8s linear forwards;
}
.progress .progress-value {
width: 79%;
height: 79%;
border-radius: 50%;
background: none;
font-size: 24px;
color: black;
line-height: 135px;
text-align: center;
position: absolute;
top: 5%;
left: 5%;
}
.progress.one .progress-bar {
border-color: black;
}
.progress.one .progress-left .progress-bar {
animation: loading-1 1s linear forwards 1.8s;
}
#keyframes loading {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(180deg);
transform: rotate(180deg);
}
}
#keyframes loading-1 {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
}
<div class="container bg-danger">
<div class="row mt-5">
<div class="progress one">
<span class="progress-left">
<span class="progress-bar"></span>
</span>
<span class="progress-right ">
<span class="progress-bar"></span>
</span>
<div class="progress-value">73%</div>
</div>
</div>
</div>
As I commented, the trivial solution is to rotate the whole animation:
* {
box-sizing:border-box;
}
.progress {
width: 150px;
height: 150px;
background: none;
margin: 0 auto;
box-shadow: none;
position: relative;
transform: scaleX(-1);
}
.progress-value {
transform: scaleX(-1);
}
.progress:after {
content: "";
width: 100%;
height: 100%;
border-radius: 50%;
border: 3px solid #fff;
position: absolute;
top: 0;
left: 0;
opacity: 0.5;
}
.progress>span {
width: 50%;
height: 100%;
overflow: hidden;
position: absolute;
top: 0;
z-index: 1;
}
.progress .progress-left {
left: 0;
}
.progress .progress-bar {
width: 100%;
height: 100%;
background: none;
border-width: 2px;
border-style: solid;
position: absolute;
top: 0;
}
.progress .progress-left .progress-bar {
left: 100%;
border-top-right-radius: 80px;
border-bottom-right-radius: 80px;
border-left: 0;
-webkit-transform-origin: center left;
transform-origin: center left;
}
.progress .progress-right {
right: 0;
}
.progress .progress-right .progress-bar {
left: -100%;
border-top-left-radius: 80px;
border-bottom-left-radius: 80px;
border-right: 0;
-webkit-transform-origin: center right;
transform-origin: center right;
animation: loading 1.8s linear forwards;
}
.progress .progress-value {
width: 79%;
height: 79%;
border-radius: 50%;
background: none;
font-size: 24px;
color: black;
line-height: 135px;
text-align: center;
position: absolute;
top: 5%;
left: 5%;
}
.progress.one .progress-bar {
border-color: black;
}
.progress.one .progress-left .progress-bar {
animation: loading-1 1s linear forwards 1.8s;
}
#keyframes loading {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(180deg);
transform: rotate(180deg);
}
}
#keyframes loading-1 {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
}
<div class="progress one">
<span class="progress-left">
<span class="progress-bar"></span>
</span>
<span class="progress-right ">
<span class="progress-bar"></span>
</span>
<div class="progress-value">73%</div>
</div>
By the way here is another idea that rely on less code. The trick is to consider clip-path where you will adjust the position of the different points in order to create the needed animation
.box {
width:150px;
height:150px;
margin:20px;
box-sizing:border-box;
font-size:30px;
display:flex;
align-items:center;
justify-content:center;
position:relative;
z-index:0;
}
.box:before {
content:"";
position:absolute;
z-index:-1;
top:0;
left:0;
right:0;
bottom:0;
border:5px solid #000;
border-radius:50%;
transform:rotate(45deg);
clip-path:polygon(50% 50%,0 0,0 0,0 0, 0 0,0 0);
animation:change 2s linear forwards;
}
#keyframes change {
25% {
clip-path:polygon(50% 50%,0 0, 0 100%,0 100%,0 100%,0 100%);
}
50% {
clip-path:polygon(50% 50%,0 0,0 100%, 100% 100%, 100% 100%,100% 100%);
}
75% {
clip-path:polygon(50% 50%,0 0,0 100%,100% 100%, 100% 0,100% 0);
}
100% {
clip-path:polygon(50% 50%,0 0,0 100%,100% 100%, 100% 0, 0% 0%);
}
}
body {
background:pink;
}
<div class="box">
73%
</div>
To better understand the animation, add background and remove the radius. We basically have 6 points in the polygon where 2 are fixed (the center (50% 50%) and top one (0 0)) then we move the 4 others to put them in the corners. The trick is to move them together and we leave one at each corner (each state of the animation).
.box {
width:100px;
height:100px;
margin:50px;
box-sizing:border-box;
font-size:30px;
display:flex;
align-items:center;
justify-content:center;
position:relative;
z-index:0;
background:rgba(0,0,0,0.5);
}
.box:before {
content:"";
position:absolute;
z-index:-1;
top:0;
left:0;
right:0;
bottom:0;
border:5px solid #000;
background:red;
transform:rotate(45deg);
clip-path:polygon(50% 50%,0 0,0 0,0 0, 0 0,0 0);
animation:change 5s linear forwards;
}
#keyframes change {
25% {
clip-path:polygon(50% 50%,0 0, 0 100%,0 100%,0 100%,0 100%);
}
50% {
clip-path:polygon(50% 50%,0 0,0 100%, 100% 100%, 100% 100%,100% 100%);
}
75% {
clip-path:polygon(50% 50%,0 0,0 100%,100% 100%, 100% 0,100% 0);
}
100% {
clip-path:polygon(50% 50%,0 0,0 100%,100% 100%, 100% 0, 0% 0%);
}
}
body {
background:pink;
}
<div class="box">
73%
</div>
With this code you have the full animation, simply adjust the final state or remove some states to stop it where you want.
Ex with 75% (we remove the last state)
.box {
width:150px;
height:150px;
margin:20px;
box-sizing:border-box;
font-size:30px;
display:flex;
align-items:center;
justify-content:center;
position:relative;
z-index:0;
}
.box:before {
content:"";
position:absolute;
z-index:-1;
top:0;
left:0;
right:0;
bottom:0;
border:5px solid #000;
border-radius:50%;
transform:rotate(45deg);
clip-path:polygon(50% 50%,0 0,0 0,0 0, 0 0,0 0);
animation:change 3s linear forwards;
}
#keyframes change {
33% {
clip-path:polygon(50% 50%,0 0, 0 100%,0 100%,0 100%,0 100%);
}
66% {
clip-path:polygon(50% 50%,0 0,0 100%, 100% 100%, 100% 100%,100% 100%);
}
100% {
clip-path:polygon(50% 50%,0 0,0 100%,100% 100%, 100% 0,100% 0);
}
}
body {
background:pink;
}
<div class="box">
75%
</div>
With 66% (we remove the last state and we change the percentage of the third one)
.box {
width:150px;
height:150px;
margin:20px;
box-sizing:border-box;
font-size:30px;
display:flex;
align-items:center;
justify-content:center;
position:relative;
}
.box:before {
content:"";
position:absolute;
z-index:-1;
top:0;
left:0;
right:0;
bottom:0;
border:5px solid #000;
border-radius:50%;
transform:rotate(45deg);
clip-path:polygon(50% 50%,0 0,0 0,0 0, 0 0,0 0);
animation:change 2s linear forwards;
}
#keyframes change {
33% {
clip-path:polygon(50% 50%,0 0, 0 100%,0 100%,0 100%,0 100%);
}
66% {
clip-path:polygon(50% 50%,0 0,0 100%, 100% 100%, 100% 100%,100% 100%);
}
100% {
clip-path:polygon(50% 50%,0 0,0 100%,100% 100%, 100% 0,100% 40%);
}
}
<div class="box">
75%
</div>
with 10% (only one state)
.box {
width:150px;
height:150px;
margin:20px;
box-sizing:border-box;
font-size:30px;
display:flex;
align-items:center;
justify-content:center;
position:relative;
}
.box:before {
content:"";
position:absolute;
z-index:-1;
top:0;
left:0;
right:0;
bottom:0;
border:5px solid #000;
border-radius:50%;
transform:rotate(45deg);
clip-path:polygon(50% 50%,0 0,0 0,0 0, 0 0,0 0);
animation:change 1s linear forwards;
}
#keyframes change {
100% {
clip-path:polygon(50% 50%,0 0, 0 40%,0 40%,0 40%,0 40%);
}
}
body {
background:pink;
}
<div class="box">
10%
</div>
This progress works in new blink/webkit browsers since it uses conic-gradient(). In addition, to change the progress we use css variables, so animation will require JS.
The idea is to create a conic gradient of black to transparent, and change the degrees according to the progress. To get a line instead of a circle, I use an inner gradient from white to white, that doesn't cover the border (background-clip: content-box) as suggested by #TemaniAfif.
Play with the values of the input box to see the progress.
const progress = document.querySelector('.circular-progress')
const updateProgress = value => {
progress.style.setProperty('--percentage', `${value * 3.6}deg`)
progress.innerText = `${value}%`
}
updateProgress(36)
document.querySelector('input')
.addEventListener('input', e => {
updateProgress(e.currentTarget.value)
})
.circular-progress {
display: flex;
width: 150px;
height: 150px;
border:5px solid transparent;
border-radius: 50%;
align-items: center;
justify-content: center;
font-size: 1.5em;
background:
linear-gradient(#fff, #fff) content-box no-repeat,
conic-gradient(black var(--percentage,0), transparent var(--percentage,0)) border-box;
--percentage: 0deg;
}
<div class="circular-progress"></div>
<br />
Progress value: <input type="number" min="0" max="100" value="36">
And for the other direction (added by #TemaniAfif):
const progress = document.querySelector('.circular-progress')
const updateProgress = value => {
progress.style.setProperty('--percentage', `${value * 3.6}deg`)
progress.innerText = `${value}%`
}
updateProgress(36)
document.querySelector('input')
.addEventListener('input', e => {
updateProgress(e.currentTarget.value)
})
.circular-progress {
display: flex;
width: 150px;
height: 150px;
border:5px solid transparent;
border-radius: 50%;
align-items: center;
justify-content: center;
font-size: 1.5em;
background:
linear-gradient(#fff, #fff) content-box no-repeat,
conic-gradient(from calc(-1*var(--percentage)), black var(--percentage,0), transparent var(--percentage,0)) border-box;
--percentage: 0deg;
}
<div class="circular-progress"></div>
<br />
Progress value: <input type="number" min="0" max="100" value="36">
A variation on the same idea, is to create progress circle with multiple colors, and then hide it using a gradient from transparent to white. Make the transparent area bigger to expose the colored line.
const progress = document.querySelector('.circular-progress')
const updateProgress = value => {
progress.style.setProperty('--percentage', `${value * 3.6}deg`)
progress.innerText = `${value}%`
}
updateProgress(80)
document.querySelector('input')
.addEventListener('input', e => {
updateProgress(e.currentTarget.value)
})
.circular-progress {
display: flex;
width: 150px;
height: 150px;
border: 5px solid transparent;
border-radius: 50%;
align-items: center;
justify-content: center;
font-size: 1.5em;
background:
linear-gradient(#fff, #fff) content-box no-repeat,
conic-gradient(transparent var(--percentage, 0), white var(--percentage, 0)) border-box,
conic-gradient(green 120deg, yellow 120deg 240deg, red 240deg) border-box;
--percentage: 0deg;
}
<div class="circular-progress"></div>
<br /> Progress value: <input type="number" min="0" max="100" value="80">
I am creating trapezoid using following CSS:
.trapezoid {
border-bottom: 100px solid red;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
height: 0;
width: 100px;
background: linear-gradient(red, yellow);
}
<div class='trapezoid'></div>
The linear-gradient attribute is not working. I want the trapezoid as shadow i.e its color should eventually fade away. Can anyone please help me on this?
Or use a transform on a suitably sized element (or pseudo-element).
.trapezoid {
width: 100px;
height: 100px;
margin: auto;
transform: perspective(100px) rotateX(40deg);
background: linear-gradient(red, yellow);
}
<div class='trapezoid'></div>
You cannot apply gradient in this way as you are using border and your element has a height of 0 so background won't be visible.
Instead you can try to use multiple gradient to create the shape:
.trapezoid {
height: 100px;
width: 200px;
background:
linear-gradient(to bottom left,white 50%,transparent 52%) 100% 0/40px 100% no-repeat,
linear-gradient(to bottom right,white 50%,transparent 52%) 0 0/40px 100% no-repeat,
linear-gradient(red, yellow);
}
<div class='trapezoid'></div>
Or use clip-path:
.trapezoid {
height: 100px;
width: 200px;
background: linear-gradient(red, yellow);
-webkit-clip-path: polygon(20% 0%, 80% 0%, 100% 100%, 0% 100%);
clip-path: polygon(20% 0%, 80% 0%, 100% 100%, 0% 100%);
}
<div class='trapezoid'></div>
Another method with skew and pseudo-element:
.trapezoid {
height: 100px;
width: 200px;
position: relative;
}
.trapezoid:before,
.trapezoid:after{
content: "";
position: absolute;
top: 0;
bottom: 0;
right: 0;
width: 60%;
background: linear-gradient(red, yellow);
transform:skew(20deg);
transform-origin:bottom right;
}
.trapezoid:after {
left: 0;
transform:skew(-20deg);
transform-origin:bottom left;
}
<div class='trapezoid'></div>
I have an image as shown below:
Here is my HTML:
<div class="diamond-border" style="left:10px;top:10px"></div>
<div class="diamond" style="left:13px;top:13px" >
<img src="http://res.cloudinary.com/demo/image/upload/sample.jpg" />
</div>
Here is my css:
.diamond
{
background-color: white;
height: 260px;
width: 260px;
position: absolute;
clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}
.diamond-border
{
background-color: #AAA;
height: 266px;
width: 266px;
position: absolute;
clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}
.diamond img
{
height: 300px;
width: 300px;
}
What I want:
I want to show the border around image as follows:
What I tried for that:
img
{
border: 5px solid red;
}
But the border is not showing. How do I show that border?
JSFiddle
https://jsfiddle.net/Vishal1419/gfok1bv8/
you can create a div with same height and width as your image to wrap that code and give it a border.
here is updated code from your fiddle
<div class="diamond-container">
<div class="diamond-border" style="left:10px;top:10px"></div>
<div class="diamond" style="left:13px;top:13px" >
<img src="https://res.cloudinary.com/demo/image/upload/sample.jpg" />
</div>
</div>
and css:
.diamond
{
background-color: white;
height: 260px;
width: 260px;
position: absolute;
clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}
.diamond-border
{
background-color: #AAA;
height: 266px;
width: 266px;
position: absolute;
clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}
.diamond img
{
height: 300px;
width: 300px;
}
.diamond-container{
border: 5px solid red;
height: 300px;
width: 300px;
}
here is an updated fiddle
https://jsfiddle.net/icernn03/gfok1bv8/3/
You can use css transform property to achieve that. check this fiddle:
-ms-transform: rotate(45deg);
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
https://jsfiddle.net/ggukk60j/
You can use a wrapper :
#wrapper {
border:5px solid red;
height: 300px;
width: 300px;
}
.diamond
{
background-color: white;
height: 260px;
width: 260px;
position: absolute;
clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}
.diamond-border
{
background-color: #AAA;
height: 266px;
width: 266px;
position: absolute;
clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}
.diamond img
{
height: 300px;
width: 300px;
}
<div id="wrapper">
<div class="diamond-border" style="left:10px;top:10px"></div>
<div class="diamond" style="left:13px;top:13px" >
<img src="http://res.cloudinary.com/demo/image/upload/sample.jpg" />
</div>
</div>
I want to cut image corners with transperant background. I have written following code.
body{
background-image:url('http://i.telegraph.co.uk/multimedia/archive/03589/Wellcome_Image_Awa_3589699k.jpg');
}
.Image{
position:absolute;
width:200px;
height:200px;
}
.Image img{
width:100%;
height:100%;
}
.Image:before {
position: absolute;
content: "";
border-top: 60px solid red;
border-right: 60px solid transparent;
top: -1px;
left: -1px;
}
.Image:after {
position: absolute;
content: "";
border-bottom: 60px solid red;
border-left: 60px solid transparent;
bottom: -1px;
right: -1px;
}
.blackBg{
position:absolute;
top:0;
left:0;
width:100%;
height:100%;
background:rgba(0,0,0,0.6);
}
<div class="blackBg"></div>
<div class="Image">
<img src="http://www.w3schools.com/css/img_fjords.jpg">
</div>
How can I cut image corners using css, also I don't want to use canvas or svg for this. I'd like to do it in pure CSS, are there any methods?
I want shape like this.
Removed your before and after pseudo part and added clip-path styling.
body{
background-image:url('http://i.telegraph.co.uk/multimedia/archive/03589/Wellcome_Image_Awa_3589699k.jpg');
}
.Image{
position:absolute;
width:200px;
height:200px;
}
.Image img{
width:100%;
height:100%;
-webkit-clip-path: polygon(20% 0%, 80% 0%, 100% 0%, 100% 80%, 80% 100%, 0% 100%, 0% 86%, 0% 20%);
clip-path: polygon(20% 0%, 80% 0%, 100% 0%, 100% 80%, 80% 100%, 0% 100%, 0% 86%, 0% 20%);
}
}
.blackBg{
position:absolute;
top:0;
left:0;
width:100%;
height:100%;
background:rgba(0,0,0,0.6);
}
<div class="blackBg"></div>
<div class="Image">
<img src="http://www.w3schools.com/css/img_fjords.jpg">
</div>
Rotate the container 45 deg to the right,
set overflow hidden on it.
and make the height bigger so that it won't clip the undesired corners.
Rotate the image -45deg so that it is horizontal again.
And you are done:
body {
background-image: url('http://i.telegraph.co.uk/multimedia/archive/03589/Wellcome_Image_Awa_3589699k.jpg');
}
.Image {
position: absolute;
width: 200px;
height: 400px;
transform: rotate(45deg);
overflow: hidden;
margin-top: -100px;
}
.Image img {
width: 100%;
height: 50%;
margin-top: 100px;
transform: rotate(-45deg);
}
.blackBg {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.6);
}
<div class="blackBg"></div>
<div class="Image">
<img src="http://www.w3schools.com/css/img_fjords.jpg">
</div>
You will (hopefully) soon be able to use border-corner-shape
like this (now rounded corners may appear as fallback) and no need to use pseudo elements
body{
background:green;
}
.Image{
position:absolute;
width:200px;
height:200px;
}
.Image img{
width:100%;
height:100%;
border-corner-shape: bevel;
border-radius:30px 0 30px 0;
}
.blackBg{
position:absolute;
top:0;
left:0;
width:100%;
height:100%;
background:rgba(0,0,0,0.6);
}
<div class="blackBg"></div>
<div class="Image">
<img src="http://www.w3schools.com/css/img_fjords.jpg">
</div>
You can achive desire result through adding extra element or through css pseudo elements :before & :after
body{background:#fff;}
.img-ctnr{position:relative;}
.img{width:450px;height:300px;background:purple;}
.img-ctnr:before,.img-ctnr:after{
content:'';position:absolute;display:block;
width:100px;height:100px;
background:#fff;
transform:rotate(45deg);
}
.img-ctnr:before{top:-50px;left:-50px;}
.img-ctnr:after{top:250px;left:400px;}
<div class="img-ctnr">
<div class="img"></div>
</div>
Just do this in your css:
background: linear-gradient(135deg,rgb(72, 72, 245) 95% , rgba(255, 255, 255, 0) 5%) ;
Please, help me to find the easiest way to achieve this result with just one single div?
<div></div>
You can do this:
Here is the JSFiddle demo
Snippet Example
div{
width:400px;
height:350px;
background: linear-gradient(to right, blue 50%, yellow 50%);
}
<div></div>
Try this code:
div {
height: 200px;
width: 400px;
background: blue; /* For browsers that do not support gradients */
background: -webkit-linear-gradient(left, blue 50% , yellow 50%); /* For Safari 5.1 to 6.0 */
background: -o-linear-gradient(right, blue 50%, yellow 50%); /* For Opera 11.1 to 12.0 */
background: -moz-linear-gradient(right, blue 50%, yellow 50%); /* For Firefox 3.6 to 15 */
background: linear-gradient(to right, blue 50% , yellow 50%); /* Standard syntax */
}
<div></div>
Here you go.
div {
width: 400px;
height: 200px;
background:yellow;
}
div::after {
width:50%;
height:100%;
content:"";
background: blue;
display:inline-block;
}
<div>
</div>
**Try This**
.container{
height:120px;
width:120px;
border-radius:50%;
background: linear-gradient(to right, rgb(183,88,206) 50%, rgb(170,61,200) 50%);
transform: rotateY(0deg) rotate(45deg);
}
<html>
<head>
<title>Test Box</title>
<style>
.container{
height:120px;
width:120px;
border-radius:50%;
background: linear-gradient(to right, rgb(183,88,206) 50%, rgb(170,61,200) 50%);
transform: rotateY(0deg) rotate(45deg);
}
</style>
</head>
<body>
<div class="container">
</div>
</body>
</html>
html:
<div class="blue_yellow"></div>
css:
.blue_yellow {
background: linear-gradient(to left, blue 50%, yellow 50%);
}
#leftHalf {
background-color: blue;
width: 50%;
position: absolute;
left: 0px;
height: 100%;
}
#rightHalf {
background-color: yellow;
width: 50%;
position: absolute;
right: 0px;
height: 100%;
}
Try with above CSS code