I am very new to web development and I have come across an obstacle.
I want to have the linear gradient at the bottom of the image (so the image fades into black) however I'm not sure on how to bring it there. Would I need to change the size of the background image or the gradient, I'm not too sure. I will attach my css and an image.
Any help would be appreciated! image
*{
margin:0;
padding:0;
box-sizing:border-box;
}
body{
background-color:black;
min-height:3000px;
min-width:0px;
background-image:url("images/background.png");
background-repeat:no-repeat;
}
#section{
object-fit:cover;
position:absolute;
width:100%;
height:100%;
object-fit:none;
pointer-events:none;
overflow:hidden;
top:0;
left:0;
}
section:before{
content:'';
position: absolute;
bottom: 0;
width: 100%;
height: 2000px;
background: linear-gradient(to bottom, rgba(0,0,0,0) 0%, rgba(0,0,0,0) 50%, rgba(0,0,0,0.3) 80%, #000 100%);
z-index: 100000;
}
You can just apply it directly to your body's background image.
body {
background-color:black;
min-height:3000px;
min-width:0px;
background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0%), rgba(0, 0, 0, 100%)), url("images/background.png");
background-repeat:no-repeat;
}
Related
So, I have one div
<div id="particles-js" >
and in css I have
#particles-js{
width: 100%;
height: 100%;
background-color: #b61924;
background-image: url("../js/image.jpg");
background-size: cover;
background-position: 50% 50%;
background-repeat: no-repeat;
}
but I also need to put some black overlay effects on image before it sets background.
How to do that?
image style..
.image {
width:100%;
vertical-align:top;
content:'\A';
position:absolute;
height:100%;
top:0; left:0;
background:rgba(0,0,0,0.6);
opacity:0.5;
transition: all 0.5s;
-webkit-transition: all 0.5s;
}
You might try this. It will add a black overlay to the image. You can change the rgb to rgba to make it more transparent.
background:linear-gradient(0deg, rgb(0, 0, 0), rgb(0, 0, 0)), url("../js/image.jpg");
I'm trying to add a triangle shaped linear-gradient to my css.
https://ibb.co/MZfbY0F
I have implemented this on jsFiddle. But in chrome or mozilla it shows like this -
https://ibb.co/FxR1pGQ
body {
height: 100vh;
margin: 0;
background:
linear-gradient(to top left, transparent 50%, rgba(255, 0, 0, 0.5) 51%) 0 0%/35% no-repeat,
url(https://lorempixel.com/1000/1000/) center/cover;
}
div {
height:200px;
text-align:left;
color:#fff;
padding:10px;
font-size:25px;
}
<div>
<p>Some content</p>
</div>
You should add browser prefixes for linear background
body {
height: 100vh;
margin: 0;
background: -moz-linear-gradient(to top left, transparent 50%, rgba(255,0,0,0.5) 51%) 0 0%/35% no-repeat,
url(https://lorempixel.com/1000/1000/) center/cover; /* FF3.6-15 */
background: -webkit-linear-gradient(to top left, transparent 50%,rgba(255,0,0,0.5) 51%) 0 0%/35% no-repeat,
url(https://lorempixel.com/1000/1000/) center/cover; /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to top left, transparent 50%,rgba(255,0,0,0.5) 51%) 0 0%/35% no-repeat,
url(https://lorempixel.com/1000/1000/) center/cover; /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00000000', endColorstr='#80ff0000',GradientType=0 ) 0 0%/35% no-repeat,
url(https://lorempixel.com/1000/1000/) center/cover; /* IE6-9 */
}
div {
height:200px;
text-align:left;
color:#fff;
padding:10px;
font-size:25px;
}
<div>
<p>Some content</p>
</div>
try this.
#triangle-topleft:after {
width: 0;
height: 0;
border-top: 100px solid red;
border-right: 100px solid transparent;
content: '';
position: absolute;
left: 0;
z-index: -1;
}
<div id="triangle-topleft">some Text</div>
i'm struggling with clip-path property in order to create an abstract background and i don't want to use an image or svg file, i tried with that property but i can't achieve this result :
enter image description here
my basic code:
.bg{
height: 100vh;
margin: 0;
}
.shape-1{
-webkit-clip-path: polygon(0 0, 10% 45%, 100% 0);
clip-path: polygon(0 10%, 40% 36%, 100% 0);
background: #3e19c6;
height: 100%;
width: 100%;
position: absolute;
margin: 0;
z-index: -1;
}
.shape-2{
-webkit-clip-path: polygon(0 62%, 100% 21%, 100% 100%, 0% 100%);
clip-path: polygon(0 62%, 90% 21%, 100% 100%, 0% 85%);
background: #c61951;
height: 100%;
width: 100%;
position: absolute;
margin: 0;
z-index: -1;
}
<div class="bg">
<div class="shape-1"> </div>
<div class="shape-2"> </div>
</div>
You can achieve this considering multiple background and gradient and only one element. It will also be responsive:
body {
margin:0;
height:100vh;
background:
linear-gradient(to top left,transparent 49.5%, #3e19c6 50%) top/100% 30%,
linear-gradient(to bottom right,transparent 49.5%, #c61951 50%) 0 30%/100% 30%,
linear-gradient(#c61951,#c61951) bottom/100% 49.1%;
background-repeat:no-repeat;
}
Here is another idea with skew transformation and pseudo elements:
body {
margin:0;
height:100vh;
position:relative;
overflow:hidden;
}
body::before,
body::after {
content:"";
position:absolute;
left:0;
width:100%;
transform-origin:right;
transform:skewY(-8deg);
}
body::before {
bottom:100%;
height:100vh;
background:#3e19c6;
}
body::after {
bottom:0;
height:80%;
background:#c61951;
}
And here is the clip-path solution:
body {
margin:0;
height:100vh;
position:relative;
overflow:hidden;
}
body::before,
body::after {
content:"";
position:absolute;
left:0;
width:100%;
}
body::before {
top:0;
height:25%;
background:#3e19c6;
-webkit-clip-path:polygon(0 0,100% 0,0 100%);
clip-path:polygon(0 0,100% 0,0 100%);
}
body::after {
bottom:0;
height:75%;
background:#c61951;
-webkit-clip-path:polygon(0% 33.33%,100% 0,100% 100%,0 100%);
clip-path:polygon(0% 33.33%,100% 0,100% 100%,0 100%);
}
Update: It appears that a scrollbar is appearing for half a second, which pushes the animation to the left. Then when the scrollbar disappears, the animation shifts back into the middle. What is going on? How can I fix it?
I tried adding this line of code to my PHP file. It should be the very first thing that loads. But, the scrollbar still appears for half a second.
echo " <style> * {overflow: hidden;} </style> ";
I have a loading screen. I am using CSS to create the animation. During the loading, the animation works well but it doesn't stay perfectly in its spot. After about 2 seconds, the animation's location makes a very small change in position. How can I fix it so that the animation remains perfectly fixed in the center of the screen?
#loading_screen {
background: #add9e4;
background: -moz-radial-gradient(center, circle cover, #f7fbfc 0%, #add9e4 100%);
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%, #f7fbfc), color-stop(100%, #add9e4));
background: -webkit-radial-gradient(center, circle cover, #f7fbfc 0%, #add9e4 100%);
background: -o-radial-gradient(center, circle cover, #f7fbfc 0%, #add9e4 100%);
background: -ms-radial-gradient(center, circle cover, #f7fbfc 0%, #add9e4 100%);
background: radial-gradient(center, circle cover, #f7fbfc 0%, #add9e4 100%);
background-color: #f7fbfc;
}
.loader_animation {
border: 16px solid lightgrey;
border-top: 16px solid blue;
border-radius: 50%;
width: 60px;
height: 60px;
animation: spin 2s linear infinite;
}
#keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
<div id="loading_screen" style="overflow:hidden; position:fixed; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%; border:none; margin:0; padding:0; z-index:999999;">
<div style="display:flex; justify-content:center; align-items:center; width:100%; height:100%;">
<div class="loader_animation"></div>
</div>
</div>
I'm tying to create an H2 with a box-show below the bottom border
here is my "base" code :
<div class="bloc-principal">
<h2 id="toto">My H2</h2>
</div>
<style type="text/css">
#toto{
box-shadow: 0 4px 2px -2px gray;
}
</style>
But i want to get this result : http://www.hostingpics.net/viewer.php?id=275479boxshadow.png
There are no border on the other side, just this little shadow on the middle of bottom side.
I tried to find tutorials but i didn't get the same result AT ALL....
I think a multi-color/fading shadow is beyond the capabilities of the box-shadow property. I used an absolute positioned element with that gradient and placed it on top of the text.
http://jsfiddle.net/efdJA/
#toto {
position:relative;
background-color:white;
height:100px;
border:1px solid red;
}
#toto:before {
background: rgb(255,255,255);
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIxMDAlIiB5Mj0iMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ZmZmZmZiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjUwJSIgc3RvcC1jb2xvcj0iI2UyZTJlMiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNmZmZmZmYiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(left, rgba(255,255,255,1) 0%, rgba(226,226,226,1) 50%, rgba(255,255,255,1) 100%);
background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(255,255,255,1)), color-stop(50%,rgba(226,226,226,1)), color-stop(100%,rgba(255,255,255,1)));
background: -webkit-linear-gradient(left, rgba(255,255,255,1) 0%,rgba(226,226,226,1) 50%,rgba(255,255,255,1) 100%);
background: -o-linear-gradient(left, rgba(255,255,255,1) 0%,rgba(226,226,226,1) 50%,rgba(255,255,255,1) 100%);
background: -ms-linear-gradient(left, rgba(255,255,255,1) 0%,rgba(226,226,226,1) 50%,rgba(255,255,255,1) 100%);
background: linear-gradient(to right, rgba(255,255,255,1) 0%,rgba(226,226,226,1) 50%,rgba(255,255,255,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#ffffff',GradientType=1 );
position:absolute;
bottom:0;
left:0;
width:100%;
height:10px;
content:'';
}
Sorry for the horrendous background gibberish, I used the amazing CSS Gradient Generator.
Add a clipping to the shadow layer so you can make your box also semi transparant
#toto {
position:relative;
background: rgba(8,55,81,0.8);
height:100px;
}
#toto:after {
position: absolute;
width: 90%;
height: 5%;
left: 5%;
border-radius: 50%;
z-index: -1;
bottom: 0%;
content: "";
box-shadow: 0 4px 12px rgba(0,0,0,0.8);
clip:rect(8px,auto,40px,auto);
}