I need to make the profile image corner should be blur border. But in my code I can't get exactly.
I need result should be like this:
But my code, blur border is repeated its self. Because, the non blur image also have the same corner. Seems the corner is repeated.
effet {
width: 400px;
height: 125px;
margin: 0 auto 50px auto;
}
.profile-box {
width: 150px;
height: 150px;
margin-left: 40px;
border: none !important;
padding: 19.5px 10px;
display: block;
}
.min_cir {
border-radius: 50%;
border-radius: 50%;
position: absolute;
top: 0;
}
.filtre--r {
-webkit-mask: -webkit-radial-gradient(center, closest-side, transparent 30%, black 80%);
-webkit-mask: radial-gradient(closest-side at center, transparent 50%, black 110%);
-webkit-filter: blur(2px);
mask: url('#mask-radial');
filter: blur(2px);
transform: scale(1.1);
position: absolute;
top: 0;
}
<div class="profile-box">
<div class="media">
<a class="pull-left" href="">
<div class="effet">
<img class="filtre filtre--r min_cir" src="http://i.imgur.com/oH1698V.jpg" />
<img class="min_cir" src="http://i.imgur.com/oH1698V.jpg">
</div>
</a>
</div>
</div>
I need to cut out the non-blur image as per the width of the blur corner.
The scale() method increases or decreases the size of an element (according to the parameters given for the width and height). I think you can achieve needed result by using different vertical and horizontal paramateres for scale() method. Currently you apply 1.1 magnitude for width and height. This is right for forms that have a shape of a square (equal width and height) whereas your image is rectangular( width and height are not equal). Therefore you can write scale() method for example like this : transform: scale(1.09, 1.13);
You can give following way:
Remove scaling first, because it will display like repeating the image.
Then put second image inside another div and give following css as per given in example. Here in example div is imgDiv
And parent div of second image i.e. imgDiv is overflow:hidden and give left and top value and give height and width is (image div - 50px(if want 15px blur)) do the trick.
And give same height and width of both image. Here i give same size as original image.
effet {
width: 400px;
height: 125px;
margin: 0 auto 50px auto;
}
.profile-box {
width: 150px;
height: 150px;
margin-left: 40px;
border: none !important;
padding: 19.5px 10px;
display: block;
}
.min_cir {
border-radius: 50%;
border-radius: 50%;
position: absolute;
top: -20px;
left: -20px;
}
.filtre--r {
-webkit-mask: -webkit-radial-gradient(center, closest-side, transparent 30%, black 80%);
-webkit-mask: radial-gradient(closest-side at center, transparent 50%, black 110%);
-webkit-filter: blur(4px);
mask: url('#mask-radial');
filter: blur(4px);
position: absolute;
top: 0;
left:0;
}
.imgDiv{
border-radius: 50%;
height: 266px;
left: 20px;
overflow: hidden;
position: absolute;
top: 20px;
width: 660px;
}
img{
width: 700px;
height: 306px;
}
<div class="profile-box">
<div class="media">
<a class="pull-left" href="">
<div class="effet">
<img class="filtre filtre--r min_cir" src="http://i.imgur.com/oH1698V.jpg" />
<div class="imgDiv">
<img class="min_cir" src="http://i.imgur.com/oH1698V.jpg">
</div>
</div>
</a>
</div>
</div>
Related
Here is my html and css code:
.image-box{
max-width: 300px;
position: relative;
}
.image-box img{
max-width: 100%;
width: 100%;
object-fit: cover;
border: 8px solid #000000;
border-right: 0;
border-bottom: 0;
/* border-image: linear-gradient(to right, #000 68%, transparent 32%) 100% 1; */
}
<div class="image-box">
<figure>
<img src="https://via.placeholder.com/300" alt="">
</figure>
</div>
While running this, I receive this.
But, I want to have something like this:
If I uncomment this line
border-image: linear-gradient(to right, #000 68%, transparent 32%) 100% 1;
Then it shows half width border on top, but this also make the left border disappear and show like this.
You can do something like this using pseudo classes to make the border at the top like how you want it to be achieved:
What it does is hide the half of the border at the top.
.box {
width: 150px;
height: 150px;
background-color: black;
border-top: 5px solid red;
border-left: 5px solid red;
position: relative;
}
.box:after {
content: "";
width: 50%;
height: 5px;
background-color: white;
position: absolute;
right: 0;
top: -5px;
}
<div class="box"></div>
Disclaimer: Not an exhaustive list. Try to come up with yet another solution!
With background-image: linear-gradient()
To make a linear-gradient look like a border, we can add padding to the image and a hard color-stop to the gradient:
.image-box {
--thickness: 8px;
}
.image-box img {
padding-top: var(--thickness);
padding-left: var(--thickness);
background-image: linear-gradient(to right, black 60%, white 60%);
}
figure{margin:0;line-height:0}
<div class="image-box">
<figure>
<img src="https://via.placeholder.com/300">
</figure>
</div>
A potential problem with this is that only one side of the border may be shorter.
With Pseudo-elements
Pseudo-elements can be used for presentational styling. You can easily identify them in your CSS by their double-colons (e.g. ::before, ::marker).
Sidenote: While still supported for legacy reasons, they can also be written with a single-colon (e.g. :before). Do yourself a favour and use the double-colons.
We can use pseudo-elements to create the border.
I will use custom properties to make the code easier to change.
Personally, I enjoy the method Placing behind the most, because that way no bleeding through of the parent's background should happen in extreme (zoom) cases.
Composition
Composite the border with ::before for the left and ::after for the top side. Since these are separate elements, we can define their width and height individually:
.image-box::before, .image-box::after {
content: "";
position: absolute;
top: 0;
left: 0;
background-color: black;
}
.image-box::before { /* Left */
width: var(--thickness);
height: 100%;
}
.image-box::after { /* Top */
width: 60%;
height: var(--thickness);
}
.image-box {
--thickness: 8px;
position: relative;
/* Leave space for border */
padding-top: var(--thickness);
padding-left: var(--thickness);
max-width: 300px;
box-sizing: border-box;
}
.image-box img {max-width:100%}
figure{margin:0;line-height:0}
<div class="image-box">
<figure>
<img src="https://via.placeholder.com/300">
</figure>
</div>
Placing behind
Place the image on top of a pseudo-element to make it look like a (partially wide) border:
.image-box::before, .image-box>figure {
grid-area: 1/1 / 1/1; /* Place both on first grid-cell */
}
.image-box::before {
content: "";
width: 60%;
height: 100%;
background-color: black;
}
.image-box {
--thickness: 8px;
max-width: 300px;
display: grid;
}
.image-box img {
/* Leave space for border */
padding-top: var(--thickness);
padding-left: var(--thickness);
width: 100%;
box-sizing: border-box;
}
figure{margin:0;line-height:0}
<div class="image-box">
<figure>
<img src="https://via.placeholder.com/300">
</figure>
</div>
Using clip-path: polygon()
Specify each point of the "top-left corner" shape in polygon():
.image-box {
position: relative;
padding-top: 8px;
padding-left: 8px;
max-width:300px;
}
.image-box::before {
--thickness: 8px;
content: "";
position: absolute;
top: 0;
left: 0;
width: 60%;
height: 100%;
clip-path: polygon(
0 0,
100% 0,
100% var(--thickness),
var(--thickness) var(--thickness),
var(--thickness) 100%,
0 100%);
background-color: black;
}
figure {margin:0;line-height:0}
<div class="image-box">
<figure>
<img src="https://via.placeholder.com/300">
</figure>
</div>
Why not use border?
Edit: Apparently border-image is a thing. See an example. Bottom section is therefore outdated.
Unfortunately, each side of a border can only be a single color. This means the black & white top border is not possible by only using the border property.
A solution to this would be to redraw over part of the border that we don't want:
#example {
padding: 1rem;
background-color: slateblue;
}
.image-box {
--thickness: 8px;
position: relative;
border: 0 solid black;
border-top-width: var(--thickness);
border-left-width: var(--thickness);
max-width: 300px;
}
.image-box::after {
content: "";
position: absolute;
top: calc(-1 * var(--thickness));
right: 0;
/* 100% - <length> + <thickness left-side> */
width: calc(100% - 60% + var(--thickness));
height: var(--thickness);
background-color: white;
}
body {
display: flex;
flex-direction: column;
gap: 1rem;
}
figure{margin:0;line-height:0}
<div class="image-box">
<figure>
<img src="https://via.placeholder.com/300">
</figure>
</div>
<div id="example">
<div class="image-box">
<figure>
<img src="https://via.placeholder.com/300">
</figure>
</div>
</div>
But as you can see, this way we will lose the background of the parent. Hard-coding some color only works if the parent's background is a solid color. If the parent's background is an image, this won't work.
Also, having to tell .image-box the color to draw over with is redundant information (because the background already exists) and would only cause more mental overhead for the developer.
you are almost good with border-image. You need to correctly define the slice.
.image-box {
max-width: 300px;
position: relative;
}
.image-box img {
max-width: 100%;
width: 100%;
object-fit: cover;
border: 8px solid #000000;
border-right: 0;
border-bottom: 0;
border-image: linear-gradient(to right, #000 68%, transparent 32%) 1;
}
<div class="image-box">
<figure>
<img src="https://via.placeholder.com/300" alt="">
</figure>
</div>
I need to create a div with the top left and right border with different heights, with a radius of 50px at each top end respectively, plus a linear gradient background color.
Do you know if it is possible to create it with CSS and HTML?
Thanks for your comments.
It should look like below:
You'll need 2 divs for this, with 1 nested in the other.
Rotate the child element using transform: rotate(deg) and hide the overflowing sides by applying overflow:hidden to the parent.
.parent {
background-color: #E6E6E6;
width: 200px;
height: 200px;
overflow: hidden;
padding-top: 8px;
}
.child {
height: 222px;
width: 217px;
margin-left: -10px;
background: linear-gradient( 0deg, #FFFFFF, #E9F3FF);
border-radius: 25px 25px 0px 0px;
transform: rotate( -6deg);
}
<div class="parent">
<div class="child">
</div>
</div>
Yes, with a lot of manipulation (building on the other answer but closer to the example):
We need three divs. The outer one is the wrapper (invisible). The second one is the one with "different heights" and a gradient, which is rotated to give the "different heights" illusion. Finally, we have another div that's almost the same as the second one but fills in the empty space caused by the rotation of the second one.
#wrapper {
height: 500px;
width: 300px;
background-color: transparent;
position: relative;
overflow: hidden;
}
#f {
position: absolute;
width: 100%;
height: 150%;
top: 20px;
left: 18px;
background: linear-gradient( 0deg, #FFFFFF, #E9F3FF);
border-radius: 10px 25px 0 0;
transform: rotate(-3deg);
}
#g {
position: absolute;
width: 100%;
height: 150%;
top: 50px;
background: linear-gradient( 0deg, #FFFFFF, #E9F3FF);
}
<div id="wrapper">
<div id="f"></div>
<div id="g"></div>
</div>
I'm Trying to customize a box shadow to shape like a triangle behind an image. Like this:
But i don't know if theres a way to doing it using box shadow.
This is my code so far.
#image{
width: 200px;
box-shadow: -10px 10px #ff9900;
}
<img src="https://placeimg.com/200/180/any" id="image" />
A simple border with gradient will do it and it will be responsive:
#image {
border: 10px solid transparent;
border-image: linear-gradient(to bottom left, transparent 60%, #ff9900 60.5%) 10;
}
<img src="https://placeimg.com/180/150/any" id="image" />
<img src="https://placeimg.com/250/150/any" id="image" />
Almost the same but with background:
.box{
width:200px;
height:150px;
padding:10px; /*control the space*/
background:
url(https://placeimg.com/180/150/any) center/cover content-box,
linear-gradient(to bottom left, transparent 60%, #ff9900 60.5%);
}
<div class="box"></div>
I think the box-shadow property cannot be modeled to be a format different than your father element.
For example, you cannot make a triangle shadow for a square image, like your question.
Try to make a triangle in css and make that with a realative position. Then, use your image with a absolute position.
#triangle-bottomleft {
width: 0;
height: 0;
border-bottom: 100px solid red;
border-right: 100px solid transparent;
position: relative;
margin-top: 30px;
}
#image {
position: absolute;
top: 20px;
left: 17px;
}
<div id="triangle-bottomleft"></div>
<img src="https://placeimg.com/100/100/any" title="title of image" alt="alt of image" id="image">
I hope this will helpu.
I would suggest nesting the triangle and refrain from using position: absolute; in this case:
#img {
position: relative;
width: 200px;
background: url(https://placeimg.com/200/150) no-repeat right top;
padding: 10px 10px 0 0;
}
#triangle {
position: relative;
border-bottom: 150px solid orange;
border-right: 200px solid transparent;
z-index: -1;
}
<div id="img">
<div id="triangle"></div>
</div>
If compatibility with IE is a non-issue you could also use clip-path:
#img {
position: relative;
width: 200px;
height: 150px;
background: url(https://placeimg.com/200/150) no-repeat right top;
padding: 10px 10px 0 0;
}
#triangle {
position: relative;
width: 100%;
height: 100%;
clip-path: polygon(0 0, 0% 100%, 100% 100%);
background-color: orange;
z-index: -1;
}
<div id="img">
<div id="triangle"></div>
</div>
How to make multiple images gradient blend to each other at only certain area as in the attached image below using CSS?
What I've tried:
.container {
position: relative;
display: flex;
height: 200px;
}
.container:before {
content: '';
position: absolute;
width: 80px;
top: 0;
bottom: 0;
right: 50%;
margin-right: -40px;
background: url(https://www.w3schools.com/w3css/img_fjords.jpg);
filter: blur(5px);
-webkit-filter: blur(5px);
}
.container > div {
flex: 1;
background-size: 100% 100%;
}
<div class="container">
<div style="backgroud-image:url(https://www.w3schools.com/w3css/img_fjords.jpg)"></div>
<div style="background-image:url(https://www.w3schools.com/w3css/img_fjords.jpg)"></div>
</div>
However, there's no fading/transition respecting to the background images as shown in below image:
UPDATE
I haven't receive any solid answer for my question but this code seems like the closest answer I can get till date.
A modification from PEN BY Peter Ramsing
<div class="hero-image">
<img src="http://static.peter.coffee/codepen-assets/keyboard-background.jpg" />
</div>
<div class="hero-before">
<img src="http://static.peter.coffee/codepen-assets/keyboard-background.jpg" />
</div>
<style>
img {
/* To contain the image to the confines of the div */
max-width: 100%;
}
.hero-image {
max-width: 100%;
width: 800px;
margin: auto;
}
.hero-before {
max-width: 100%;
width: 800px;
margin: auto;
}
.hero-image::after {
display: block;
position: relative;
background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0) 0, #fff 100%);
margin-top: -50px;
height: 40px;
width: 100%;
content: '';
}
.hero-before::after {
display: block;
position: relative;
background-image: linear-gradient(to bottom, #fff 0%, rgba(255, 255, 255, 0) 100%);
margin-top: -345px;
height: 50px;
width: 100%;
content: '';
}
</style>
You may use some pseudo element that you put between the two images and apply linear gradient on it. By using the same colors you will create this effet. You may notice that the solution will work by using background color and also backround image, you simply need to respect the color used in the background and apply them to the pseudo element.
Here is an example, you may adjust the width of the pseudo element depending on your needs :
.container {
position: relative;
display: flex;
min-height: 100px;
margin-bottom:20px;
}
.container:before {
content: '';
position: absolute;
width: 80px;
top: 0;
bottom: 0;
right: 50%;
margin-right: -40px;
background: linear-gradient(to right, #c3986b, #0a4b67);
}
.container>div {
flex: 1;
background-size:100% 100%;
}
<div class="container">
<div style="background:#c3986b;"></div>
<div style="background:#0a4b67;"></div>
</div>
<div class="container">
<div style="background-image:url(https://dummyimage.com/150x100/c3986b/14151a)"></div>
<div style="background-image:url(https://dummyimage.com/150x100/0a4b67/14151a)"></div>
</div>
Here is another idea with mask that will work with any kind of images
.container {
display: flex;
min-height: 300px;
margin-bottom:20px;
}
.container>div {
flex: 1;
background-size:0 0;
position:relative;
z-index:-1;
}
.container>div::before {
content:"";
position:absolute;
background-image:inherit;
background-size:cover;
background-position:center;
z-index:-1;
top:0;
bottom:0;
}
.container>div:first-child::before {
left:0;
right:-50px;
-webkit-mask:linear-gradient(to left,transparent ,#fff 50px);
mask:linear-gradient(to left,transparent ,#fff 50px);
}
.container>div:last-child::before {
right:0;
left:-50px;
-webkit-mask:linear-gradient(to right,transparent ,#fff 50px);
mask:linear-gradient(to right,transparent ,#fff 50px);
}
<div class="container">
<div style="background-image:url(https://picsum.photos/id/1074/800/800.jpg)"></div>
<div style="background-image:url(https://picsum.photos/id/1060/800/800.jpg)"></div>
</div>
<div class="container">
<div style="background-image:url(https://picsum.photos/id/1070/800/800.jpg)"></div>
<div style="background-image:url(https://picsum.photos/id/1062/800/800.jpg)"></div>
</div>
You can combine the background: linear-gradient() with Flexbox to achieve something like this:
div {
display: flex; /* displays flex-items (children) inline */
justify-content: space-around; /* horizontal alignment / icons are evenly distributed with equal space around them, i.e. all have equal space on both sides, that's why there are two units of space between them / you can also experiment with other values such as: "space-between", "space-evenly", "center" etc. */
align-items: center; /* vertically centered */
height: 100px;
background: linear-gradient(to right, #c3986b 45%, #0a4b67 55%); /* adjust the % to your needs, the sum of both needs to evaluate to 100% */
}
img {border-radius: 50%}
<div>
<img src="http://lorempixel.com/50/50/" alt="icon1">
<img src="http://lorempixel.com/50/50/" alt="icon2">
</div>
In the given example I've made the linear-gradient() to be 10% of parent's width. The number is calculated by subtraction of both values in %, 55% - 45%.
In order to increase its width, if so desired, just increase the bigger number and decrease the lower one, preferably by the same amount of %, e.g. 40% / 60%, to leave it horizontally centered. For decreasing its width, just do the opposite.
I need a css code for border blur inside of the image. Please see http://i.stack.imgur.com/w6KNa.jpg
.effet {
width: 400px;
height: 125px;
margin: 0 auto 50px auto;
}
.profile-box{
width: 150px;
height: 150px;
margin-left: 40px;
border: none !important;
padding: 19.5px 10px;
display: block;
}
.min_cir{
border-radius: 50%;
}
.filtre--r {
-webkit-mask: -webkit-radial-gradient( center, closest-side, transparent 30%, black 80%);
-webkit-mask: radial-gradient( closest-side at center, transparent 50%, black 110%);
-webkit-filter: blur(5px);
mask: url('#mask-radial');
filter: url('#filtre1');
margin-top: -307px;
}
<div class="profile-box">
<div class="media">
<a class="pull-left" href="">
<!--<img class="img-circle" src="">-->
<div class="effet">
<img class="min_cir" src="http://i.imgur.com/oH1698V.jpg">
<img class="filtre filtre--r min_cir" src="http://i.imgur.com/oH1698V.jpg">
</div>
</a>
</div>
</div>
It is worked but not like corrected blured border.. Its working with gradient style.. Can anyone help me to make the "Fixed border and rounded with blur" image in CSS Thanks.
You might want this. Just make the images position absolute and give transform: scale(1.1); to the blurred image.
.effet {
width: 400px;
height: 125px;
margin: 0 auto 50px auto;
}
.profile-box{
width: 150px;
height: 150px;
margin-left: 40px;
border: none !important;
padding: 19.5px 10px;
display: block;
}
.min_cir{
border-radius: 50%;
border-radius: 50%;
position: absolute;
top: 0;
}
.filtre--r {
-webkit-mask: -webkit-radial-gradient( center, closest-side, transparent 30%, black 80%);
-webkit-mask: radial-gradient( closest-side at center, transparent 50%, black 110%);
-webkit-filter: blur(5px);
mask: url('#mask-radial');
filter: url('#filtre1');
transform: scale(1.1);
position: absolute;
top: 0;
}
<div class="profile-box">
<div class="media">
<a class="pull-left" href="">
<!--<img class="img-circle" src="">-->
<div class="effet">
<img class="min_cir" src="http://i.imgur.com/oH1698V.jpg">
<img class="filtre filtre--r min_cir" src="http://i.imgur.com/oH1698V.jpg">
</div>
</a>
</div>
</div>
It looks like you're almost there.
I would use two images for this solution;
Layer A | z-index:1
A div with the background-image being the profile picture. I would then blur the image with css3 blur.
Layer B | z-index:2
Will be the profile pic on top of this one
Check out this stackoverflow question for some guidance. Your situation is quite similar. Good luck!
How to apply a CSS 3 blur filter to a background image