how to created a curved background on top of image - html

I have this design
How can I make the blue curved background on top of the image (I need the transparency as well) ?
I started it with a different backgournd but I don't know where to go from there. Any help will be really appreciated.
.bg {
background-image:url("https://s8.postimg.cc/rsxes8dx1/red_or_blue_pill_crimson_quill-12.jpg");
max-width: 100%;
height: 200px;
background-size: cover;
background-position: center;
position: relative;
}
.bluebg {
background-color: blue;
position: absolute;
}
<div class="bg">
<div class="bluebg">
</div>
</div>
https://jsfiddle.net/0rsLxtw5/7/

I hope the below-given snippet helps!
.bg {
background-image: url("https://s8.postimg.cc/rsxes8dx1/red_or_blue_pill_crimson_quill-12.jpg");
height: 200px;
background-size: cover;
background-position: center;
overflow: hidden;
}
.bluebg {
background: rgba(135, 206, 235, 0.5);
height: 140%;
width: 90%;
-webkit-mask-image: radial-gradient(circle at right, transparent 0, transparent 30%, black 30px);
mask-image: radial-gradient(circle at right, transparent 0, transparent 30%, black 30px);
}
<div class="bg">
<div class="bluebg"></div>
</div>

I changed your HTML like the parent as child and child as parent.
.bg {
background-image: url("https://s8.postimg.cc/rsxes8dx1/red_or_blue_pill_crimson_quill-12.jpg");
max-width: 100%;
height: 200px;
background-size: cover;
background-position: center;
position: relative;
-webkit-clip-path: circle(50% at 98% 50%);
clip-path: circle(50% at 98% 50%);
}
.bluebg {
background-color: blue;
position: absolute;
height: 200px;
width: 100%;
}
<div class="bluebg">
<div class="bg">
</div>
</div>

Related

How to get this background

Hey i have actualy this background
And i want to change it to
#dark-bg {
width: 45%;
height: 100vh;
background-color: linear-gradient(to right, #330066, #421a9b)!important;
float: left;
}
#wave {
position: relative;
content: "";
bottom: 0;
width: 50%;
height: 100vh;
float: left;
background: url(https://i.imgur.com/IJelEnu.png);
background-size: contain;
background-repeat: no-repeat;
}
body {
background-image: linear-gradient(to right, #380774 60%, #4f30c6 )!important;
}
<div id="dark-bg"></div>
<div id='wave'>
<p></p>
</div>
I don't want to use image (i want to remove wave image if possible)
How i can do that?
Use the image as a mask
#dark-bg {
height: 100vh;
width: 50%;
background: linear-gradient(to right, #330066, #421a9b);
-webkit-mask:
linear-gradient(#000 0 0) left/75% 100% no-repeat,
url(https://i.imgur.com/IJelEnu.png) top right/25% auto repeat-y;
}
body {
margin: 0;
background-image: linear-gradient(to right, #380774 60%, #4f30c6);
}
<div id="dark-bg"></div>
I tried....
Turned out pretty good if I do say so myself :)
* {
margin: 0;
padding: 0;
}
#dark-bg {
width: 50%;
height: 100vh;
background: linear-gradient(90deg, rgba(51,0,102,1) 15%, rgba(67,26,156,1) 90%);
float: left;
}
#wave {
position: absolute;
content: "";
bottom: 0;
width: 50.06%;
height: 100vh;
transform: rotate(180deg);
background: url(https://i.imgur.com/Ds3Raj2.png);
background-size: contain;
background-repeat: no-repeat;
}
body {
background-image: linear-gradient(90deg, rgba(51,0,102,1) 54%, rgba(67,26,156,1) 90%) !important;
}
<div id="dark-bg"></div>
<div id='wave'>
<p></p>
</div>

adjust height of element in css

I have this:
.test {
width: 400px;
height: 400px;
background-color: white;
display: inline-block;
background-size: 100px 30px;
background-repeaT: no-repeat;
background-position: center 30px, center center, center 140px;
border: solid 1px black;
position: relative;
overflow: hidden;
}
.test:after {
content: "";
position: absolute;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
background: linear-gradient(25deg, yellow 50%, transparent 50%);
mix-blend-mode: difference;
transition: all 1s;
}
<div class="test one"></div>
I found the pen online, and want to adjust it for my own usage, however, cannot figure out a few things.
I want to move the blue box lower, so it is not as high, but still keep the same shape. So I tried background position, as one would, and it doesn't change anything. I'm relatively an amateur in css so it is probably a silly question, but a question none the less! Appreciate the help
It's because that shape is made with linear gradient as background, so you just need to adjust gradient percentages:
From
background: linear-gradient(25deg, yellow 50%, transparent 50%);
to
background: linear-gradient(25deg, yellow 20%, transparent 20%);
.test {
width: 400px;
height: 400px;
background-color: white;
display: inline-block;
background-size: 100px 30px;
background-repeaT: no-repeat;
background-position: center 30px, center center, center 140px;
border: solid 1px black;
position: relative;
overflow: hidden;
}
.test:after {
content: "";
position: absolute;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
background: linear-gradient(25deg, yellow 20%, transparent 20%);
mix-blend-mode: difference;
transition: all 1s;
}
<div class="test one"></div>

Make a background image fill all the space when rotated

I have a div which has been rotated 45 degrees, this creates a diamond shape. Inside I have another div with a minus 45-degree rotation so the content is square I set the inner container to have 100% width & heightbut because of the rotation, it doesn't fill all the space.
I know the output I get is accurate to the code I've written because of the rotation it is 100%, so I suppose I need it larger than 100% and to scale as the browser scales.
.headerImg {
position: absolute;
top: -100px;
right: -100px;
width: 50%;
display: block;
background: #eee;
height: 95vh;
overflow: hidden;
transform: rotate(45deg);
}
.rotateBack {
width: 100%;
height: 100%;
transform: rotate(-45deg);
background-repeat: no-repeat;
background-size: cover;
background-position: center;
}
<div class="headerImg">
<div class="rotateBack" style="background-image: url('https://www.rd.com/wp-content/uploads/2017/06/05-dog-breed-Safety-Tips-to-Keep-Your-Dog-in-Top-Shape-This-Summer-508549561-Yevgen-Romanenko.jpg')">
</div>
</div>
An example JSFiddle
HTML
<div class="part">
<div class="losange">
<div class="los1">
<img src="http://farm3.staticflickr.com/2178/3531465579_8bff044e9b_z.jpg?zz=1" alt="" width="255" height="320" />
</div>
</div>
CSS
.losange, .losange div {
margin: 0 auto;
transform-origin: 50% 50%;
overflow: hidden;
width: 250px;
height: 250px;
}
.losange {
transform: rotate(45deg) translateY(10px);
}
.losange .los1 {
width: 355px;
height: 355px;
transform: rotate(-45deg) translateY(-74px);
}
.losange .los1 img {
width: 100%;
height: auto;
}
I found this and have used for a project of mine. Hope it helps you, understand the main idea.
Since the container div has fixed size you can use absolute position with the image and make it overflow by specifing negative values on top/left/bottom/right;
.headerImg {
width: 50%;
margin: auto;
display: block;
background: #eee;
height: 95vh;
overflow: hidden;
transform: rotate(45deg);
position: relative;
}
.rotateBack {
position: absolute;
top: -30%;
left: -30%;
bottom: -30%;
right: -30%;
transform: rotate(-45deg);
background-repeat: no-repeat;
background-size: cover;
background-position: center;
}
<div class="headerImg">
<div class="rotateBack" style="background-image: url('https://www.rd.com/wp-content/uploads/2017/06/05-dog-breed-Safety-Tips-to-Keep-Your-Dog-in-Top-Shape-This-Summer-508549561-Yevgen-Romanenko.jpg')">
</div>
</div>
By the way here is another way to achive what you want using clip-path:
body {
margin: 0;
}
.rotateBack {
height: 100vh;
width: 50%;
margin: auto;
clip-path: polygon(50% 0, 0 50%, 50% 100%, 100% 50%);
background-repeat: no-repeat;
background-size: cover;
background-position: center;
}
<div class="rotateBack" style="background-image: url('https://www.rd.com/wp-content/uploads/2017/06/05-dog-breed-Safety-Tips-to-Keep-Your-Dog-in-Top-Shape-This-Summer-508549561-Yevgen-Romanenko.jpg')">
</div>
Or using linear-gradient (but the background cannot be transparent):
body {
margin: 0;
}
.back {
height: 100vh;
width: 50%;
margin: auto;
background:
linear-gradient(45deg, #fff 25%, transparent 20%, transparent 75%, #fff 70%),
linear-gradient(-45deg, #fff 25%, transparent 20%, transparent 75%, #fff 20%),
url('https://www.rd.com/wp-content/uploads/2017/06/05-dog-breed-Safety-Tips-to-Keep-Your-Dog-in-Top-Shape-This-Summer-508549561-Yevgen-Romanenko.jpg') center/cover no-repeat;
}
<div class="back">
</div>

curved div with transparent top

I'm trying to create transparent div full width and height around 500px using borders but i have trouble with creating this kind of curved shape.
It should look like on the example image, the yellow shape.
.transparent_bg {
width: 100%;
height: 485px;
background: transparent;
border:solid 5px #000;
border-color:#000 transparent transparent transparent;
border-radius: 50%/200px 200px 0 0;
transform: rotate(180deg);
position: relative;
overflow:hidden;
}
.transparent_bg:after {
content: "";
width: 100%;
height: 485px;
position: absolute;
top: 0;
background: red;
}
<div class="transparent_bg"></div>
I have included a link to my work until this moment but without success.
You can use clip path in both ways (on the top element or the bottom one) and simply make top and bottom to overlay like this :
.first,
.second {
display: inline-block;
margin: 5px;
}
.first .top {
clip-path: circle(72.9% at 50% 27%);
height: 200px;
width: 200px;
background: url(https://picsum.photos/id/10/800/800) center/cover;
position: relative;
}
.first .bottom {
margin-top: -70px;
background: yellow;
height: 100px;
width: 200px;
}
.second .top {
height: 200px;
width: 200px;
background:url(https://picsum.photos/id/10/800/800) center/cover;
position: relative;
}
.second .bottom {
clip-path: polygon(0 25%, 14% 41%, 28% 51%, 49% 54%, 66% 53%, 79% 48%, 89% 39%, 100% 27%, 100% 100%, 47% 100%, 0% 100%);
margin-top: -70px;
background: yellow;
height: 100px;
width: 200px;
}
<div class="first">
<div class="top">
</div>
<div class="bottom">
</div>
</div>
<div class="second">
<div class="top">
</div>
<div class="bottom">
</div>
</div>
Here is a useful link to generate path :
https://bennettfeely.com/clippy/
Here is another idea using radial-gradient
.first {
height: 200px;
width: 400px;
background:
radial-gradient(100% 100% at top, #0000 60%, yellow 61%),
url(https://picsum.photos/id/10/800/800) center/cover;
}
<div class="first">
</div>
Using mask if you want transparency:
.first {
height: 200px;
width: 400px;
background: url(https://picsum.photos/id/10/800/800) center/cover;
-webkit-mask:radial-gradient(100% 100% at top, #fff 60%, #0000 61%);
mask:radial-gradient(100% 100% at top, #fff 60%, #0000 61%);
}
.bottom {
-webkit-mask:radial-gradient(100% 100% at top, #0000 60%, #fff 61%);
mask:radial-gradient(100% 100% at top, #0000 60%, #fff 61%);
}
body {
background:yellow;
}
<div class="first">
</div>
<div class="first bottom">
</div>
If you want to overlay top and bottom, just use clip path both ways (on the top or bottom element).`
.transparent_bg {
width: 100%;
height: 485px;
background: transparent;
border-top-left-radius: 50% 50%;
border-top-right-radius: 50% 50%;
transform: rotate(180deg);
position: relative;
overflow:hidden;
}
.transparent_bg:after {
content: "";
width: 100%;
height: 485px;
position: absolute;
top: 0;
background: red;
}
.transparent_bg {
width: 100%;
height: 485px;
background: transparent;
border-top-left-radius: 50% 50%;
border-top-right-radius: 50% 50%;
transform: rotate(180deg);
position: relative;
overflow:hidden;
}
.transparent_bg:after {
content: "";
width: 100%;
height: 485px;
position: absolute;
top: 0;
background: red;
}
<div class="transparent_bg"></div>

css clip path alternative

I am trying to do a banner for my website, a bit differently.
I want bottom border, to be kind of "arrow down" looking
Something like this: JS FIDDLE
.indexBanner {
background-image: url('https://i.stack.imgur.com/dFUnt.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
background-size: cover;
background-color: #404040;
height: 500px;
position: relative;
-webkit-clip-path: polygon(50% 0%, 100% 0, 100% 85%, 50% 100%, 0 85%, 0 0);
}
<div class="indexBanner"></div>
But currently I am using clip-path, which is not supported by Firefox and IE.
And also you can see that the "arrow shaped" border is a bit messy.
I've also tried transform: skew in which case the result was more of a "chat bubble" kind of effect.
Is there any way to do this, because I am all out of ideas.
https://jsfiddle.net/glebkema/h18w341m/
.indexBanner {
background-image: url('http://nauci.se/Flipo/assets/images/study.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
background-size: cover;
background-color: #404040;
height: 500px;
position: relative;
overflow-x: hidden;
}
.indexBanner:after {
content: "";
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 0;
height: 0;
border-left: 50vw solid white;
border-right: 50vw solid white;
border-top: 15vw solid transparent;
}
<div class="indexBanner">
</div>
I have tried changing the arrow-border to look less messy.
https://jsfiddle.net/night11/b7ch05Ln/ - updated
-webkit-clip-path: polygon(0 1%, 100% 0, 100% 60%, 50% 100%, 0 60%);