Here's an image I'd like to recreate with HTML/CSS:
The center gradient is easy enough, as are the two rings (a border around the center, and a div around that div that has its own border). The outside shadow on the left seems simple enough as well.
Here's my best approximation so far (with a matching fiddle):
<div id="youedge">
<div id="youlight" class="round border radialgradientbg">
</div>
</div>
#youedge {
border:30px solid #888;
border-radius:190px;
width:190px;height:190px;margin:50px;
box-shadow:-30px 0 0 #555;
}
#youlight { width:150px; height:150px; background-color:#2b0c0f; }
.round { border-radius:190px; }
.border { border:20px solid #777; }
body { background-color:#999; }
.radialgradientbg {
background: -moz-radial-gradient(center, ellipse cover, #4c1113 0%, #16040a 100%); /* FF3.6+ */
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%,#4c1113), color-stop(100%,#16040a)); /* Chrome,Safari4+ */
background: -webkit-radial-gradient(center, ellipse cover, #4c1113 0%,#16040a 100%); /* Chrome10+,Safari5.1+ */
}
What I can't figure out is the 3D lighting effects on the two gray borders around the center. Is there a way to accomplish this in CSS?
You could do it with a single element and using :before and :after along with linear-gradient and box-shadow..
The idea is to put two circles behind the main element with opposite linear gradient backgrounds..
.circle-3d {
position: relative;
width: 150px;
height: 150px;
background: black;
border-radius: 50%;
margin:2em;
}
.circle-3d:before {
position: absolute;
content: '';
left: -20px;
top: -20px;
bottom: -20px;
right: -20px;
background: linear-gradient(90deg, #666, #ccc);
border-radius: 50%;
z-index: -2;
box-shadow: -20px 0 10px -5px #000;
}
.circle-3d:after {
position: absolute;
left: -10px;
top: -10px;
bottom: -10px;
right: -10px;
background: linear-gradient(270deg, #222, #eee);
content: '';
border-radius: 50%;
z-index: -1;
}
<div class="circle-3d"></div>
Related
I was looking at some 80's retro design, and came across some glowy stuff, including this one:
Can this be achieved with CSS ? I mean, create a line and do some box shadow. But I have to have more glow in the middle, and less in the sides, and I am not sure how this can be accomplished in just CSS ?
Thanks in advance.
Something like this?
:root {
--clr-inner: #fed9ff;
--clr-outer: #c727c9;
}
body {
background-color: black;
text-align: center;
}
.box {
display: inline-block;
position: relative;
width: 100%;
}
.box .line-outer {
background: var(--clr-outer);
border-radius: 50%;
box-shadow: 0px 0px 25px 10px var(--clr-outer);
filter: blur(1px);
height: 4px;
overflow: hidden;
position: absolute;
width: 100%;
}
.box .line-outer .line-inner {
background: var(--clr-inner);
border-radius: 50%;
box-shadow: 0px 0px 25px 15px var(--clr-inner);
filter: blur(1px);
height: 4px;
left: 30%;
position: absolute;
top: 0;
width: 40%;
}
<div class="box">
<div class="line-outer">
<div class="line-inner"></div>
</div>
</div>
What about using a radial gradient ?
(you can adjust parameters using : https://html-css-js.com/css/generator/gradient/)
#demo {
background: #FFFFFF;
background: -moz-radial-gradient(center, #FFFFFF 0%, #A42799 64%, #000000 100%);
background: -webkit-radial-gradient(center, #FFFFFF 0%, #A42799 64%, #000000 100%);
background: radial-gradient(ellipse at center, #FFFFFF 0%, #A42799 64%, #000000 100%);
height:50px;
width:100%
}
<div id="demo"></div>
I found this picture on the internet and I would love to do this effect on my website.
I am trying to have a darker background, a lamp at the top like on the picture and a picture under it. But I want it to look like the light from the lamp is shining on a picture.
Is this possible to do?
You could use a few pseudo elements to create this effect, including a linear gradient and transforms:
Demo [hover image to see effect]
.light {
position: relative;
height: 300px;
width: 300px;
display: inline-block;
margin-top: 20px;
}
.light img {/*Image inside*/
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
}
.light:before {/*creates the bulb*/
content: "";
position: absolute;
bottom: 100%;/*places above image*/
left: 50%;
height: 20px;
width: 100px;
border-radius: 50%;
background: lightgray;
transform: translateX(-50%);/*places in center of image*/
z-index: 10;/*places in front of image*/
border: 2px solid dimgray;/*borders add 3D effect to bulb*/
border-bottom: none;
border-top: 5px solid #222;
}
.light:after {/*creates the beam*/
content: "";
position: absolute;
transition: all 0.4s;
height: 0;
width: 100px;
top: -10px;
left: 50%;
transform: translateX(-50%) perspective(400px) rotateX(45deg);/*centers, makes as trapezium*/
transform-origin: top center;
background: linear-gradient(0deg, transparent, rgba(255, 255, 255, 0.8));/*adds fading light*/
z-index: 5;/*places in front of image, but behind bulb*/
}
.light:hover:after {/*demo only, add this to .light:after in production*/
height: 80%;
}
<div class="light">
<img src="http://lorempixel.com/300/300" />
</div>
Add opacity:0.9; or opacity:0.3; to your darker background image style..
Hope this help's...
You can use a transparent png image like #Eamonn said or use gradient and shadow in CSS like in sample below:
<style type="text/css">
.light {
width: 200px;
height: 200px;
border-top-left-radius: 50%;
border-top-right-radius: 50%;
border-bottom-left-radius: 20%;
border-bottom-right-radius: 20%;
box-shadow: 0 20px 20px 5px #fff;
background: -moz-linear-gradient(top, rgba(255,255,255,0) 0%, rgba(255,255,255,0) 1%, rgba(255,255,255,0.7) 66%, rgba(255,255,255,0.79) 76%, rgba(255,255,255,1) 99%); /* FF3.6-15 */
background: -webkit-linear-gradient(top, rgba(255,255,255,0) 0%,rgba(255,255,255,0) 1%,rgba(255,255,255,0.7) 66%,rgba(255,255,255,0.79) 76%,rgba(255,255,255,1) 99%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, rgba(255,255,255,0) 0%,rgba(255,255,255,0) 1%,rgba(255,255,255,0.7) 66%,rgba(255,255,255,0.79) 76%,rgba(255,255,255,1) 99%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00ffffff', endColorstr='#ffffff',GradientType=0 ); /* IE6-9 */
</style>
<div class="light"></div>
I'm looking to make a bootstrap btn look a little differently with there being a 5 point at the bottom of its base. I know its possible to do shapes this way using the :before and :after tools and transform but I want to put text inside of them which is why I'm having so much trouble. Is it possible to deal directly with the btn class to make this effect happen?
You can use SkewY as shown in the demo below:
div {
height: 100px;
width: 500px;
display: inline-block;
border: 10px solid green;
border-bottom: none;
text-align: center;
line-height: 100px;
position: relative;
color: green;
font-size: 20px;
}
div:before,
div:after {
content: "";
border-bottom: 10px solid green;
position: absolute;
width: calc(50% + 10px);
height: 100%;
top: 0;
}
div:before {
transform: skewY(5deg);
left: -10px;
}
div:after {
transform: skewY(-5deg);
left: 50%;
}
<div>Request a Quote</div>
gradient can be a first chip approach ...
example in situation: http://codepen.io/gc-nomade/pen/wGEyvd
button {
color:green;
display:block;
width:50%;
margin:1em auto;
padding:1.5em 0 2.5em;
border:none;
background:linear-gradient(to left, green, green) top,
linear-gradient(to bottom, green,green) top left,
linear-gradient(to bottom, green,green) top right,
linear-gradient(to bottom left, transparent 45%, green 47%, green 51%, transparent 52%) bottom left,
linear-gradient(to bottom right, transparent 45%, green 47%, green 51%, transparent 52%) bottom right;
background-repeat:no-repeat;
background-size:100% 3px, 3px 70%, 3px 70%,50% 30%, 50% 30%;
}
<button>REQUEST A CODE</button>
So I have a div, content of which should always be crossed out diagonally.
I've tried few solutions with few elements that had absolute positions but it wasn't good enough, because content and size of the div that should be crossed out can vary, so crossing out should be adaptive as well.
Basically I need to make something like this: http://www.awesomescreenshot.com/0515d31j22
This should work for you.
.strike {
position: relative;
display: inline-block;
}
.strike:before {
content: "";
position: absolute;
height: 1px;
width: 120%;
background: red;
top: 50%;
left: 50%;
transform: translate(-50%, -50%) rotate(25deg);
}
<div class="strike">$55.55</div>
<br><br>
<div class="strike">$555.55</div>
<br><br>
<div class="strike">$5555.55</div>
A couple of linear gradients can do this and it will auto-size to the dimensions of the element and no degree notation is required.
div {
width: 25%;
height: 250px;
margin: 1em auto;
border:1px solid grey;
position: relative;
}
div:after {
content: '';
position: absolute;
width: 100%;
height: 100%;
top:0;
left: 0;
background:
linear-gradient(to bottom left, transparent 0%, transparent 50%, red 51%, transparent 51%, transparent 100%),
linear-gradient(to bottom right, transparent 0%, transparent 50%, red 51%, transparent 51%, transparent 100%);
}
<div></div>
I am currently using CSS3 to make an div with the left side angled like a trapezium using the following CSS adapted from this jsfiddle:
background:linear-gradient(75deg, transparent 75px, #35753f 76px);
I would like to combine the following CSS background with a radial one, to create the effect shown in the image below. However, when I do this, I lose the angled side. What is the best way to combine these two backgrounds?
Here is the radial background:
background:radial-gradient(circle closest-corner at right center, #337540 0%, #003832 100%);
Here is what it should look like:
Here is a jsfiddle of the below:
.container {
width: 1024px;
margin: 0 auto;
}
.clearfix:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
#top-banner {
position: relative;
}
#top-banner .container {
height: 350px;
}
#top-banner #banner-right {
width: 350px;
height: 350px;
background: -moz-linear-gradient(75deg, transparent 75px, #35753f 76px);
background: -o-linear-gradient(75deg, transparent 75px, #35753f 76px);
background: -webkit-linear-gradient(75deg, transparent 75px, #35753f 76px);
background: linear-gradient(75deg, transparent 75px, #35753f 76px);
position: relative;
float: right;
}
#top-banner #banner-right:after {
content: ".";
display: block;
height: inherit;
width: 5000px;
left: 350px;
top: 0;
position: absolute;
/* IE10 Consumer Preview */
background-image: -ms-radial-gradient(left center, circle closest-corner, #337540 0%, #003832 100%);
/* Mozilla Firefox */
background-image: -moz-radial-gradient(left center, circle closest-corner, #337540 0%, #003832 100%);
/* Opera */
background-image: -o-radial-gradient(left center, circle closest-corner, #337540 0%, #003832 100%);
/* Webkit (Safari/Chrome 10) */
background-image: -webkit-gradient(radial, left center, 0, left center, 140, color-stop(0, #337540), color-stop(1, #003832));
/* Webkit (Chrome 11+) */
background-image: -webkit-radial-gradient(left center, circle closest-corner, #337540 0%, #003832 100%);
/* W3C Markup, IE10 Release Preview */
background-image: ;
z-index: -100;
}
/*#top-banner #banner-right {
width:350px;
height:350px;
background:black;
position:relative;
float: right;
}
#top-banner #banner-right:before {
content:"";
position:absolute;
top:0;
left:0;
width: 0;
height: 0;
border-bottom: 350px solid white;
border-right: 40px solid transparent;
}*/
#top-banner .slider {
float: left;
height: 350px;
width: 100px;
background-color: black;
background-size: cover;
shape-outside: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}
<div id="top-banner">
<div class="container clearfix">
<div id="banner-right">
</div>
<div class="slider">
<img src="http://1.bp.blogspot.com/-9aQmrN3-xpQ/TuYsXHQygrI/AAAAAAAAAtw/cEmz4PgEQdQ/s1600/r-NEW-SPECIES-MEKONG-DELTA-huge.jpg" height="350" alt="banner-1" />
</div>
</div>
</div>
Angled div - 2 methods
The angle is created with transform: rotate and not the linear-gradient.
#1 - Rotated :before with translate 3d
In this example, translate3d(0px,0px,1px) is used to eliminate the jagged edge of the rotated element. More information here. I was reminded about this technique from this answer dealing with a similar rendering problem.
As this is a hack that should be used sparingly, their is an alternative way to mask this edge without it in the second example.
Rotate a pseudo element, :before, of the div. This will create our angled edge
The :before gets an appropriate percentage height, width: 100px and is positioned appropriately
The parent div is given overflow: hidden to cut off the background cleanly
Create a second pseudo element, :after, to extend the background to the edge of the viewport.
The gradient background is applied to :after
The :before pseudo element is given a solid background the same color as the edge of the gradient to blend
The :before and :after pseudo elements are given z-index: 1
Elements that will sit above the "background" will need position: relative and z-index: 2 to push them above it. (Like the paragraph in the example below)
Example
The linear-gradient on the body demonstrates that the div can be placed over any background.
body {
background: linear-gradient(#000 0%, #FFF 100%) no-repeat;
margin: 0;
}
div {
position: relative;
height: 350px;
overflow: hidden;
padding-left: 100px;
min-width: 500px;
}
div:before {
content: '';
display: block;
position: absolute;
height: 120%;
width: 90px;
top: -10%;
left: 90px;
background: #003832;
transform: translate3d(0px,0px,1px) rotate(-15deg);
z-index: 1;
}
div:after {
content: '';
display: block;
position: absolute;
height: 120%;
width: 100%;
top: -10%;
left: 135px;
background: radial-gradient(circle closest-corner at 50% 50%, #33753E 0%, #003832 80%);
z-index: 1;
}
p {
color: #FFF;
left: 10px;
position: relative;
z-index: 2;
}
<div>
<p>This is some text</p>
</div>
#2 - Rotated :before and :after without translate 3d
Rotate a pseudo element, :before, of the div
Apply the background to the pseudo element
The pseudo element gets height: 200% and width: 200% and is positioned appropriately
The parent div is given overflow: hidden to cut off the gradient cleanly and the rotated pseudo element becomes the background
A second pseudo element, :after, is used to help mask the jagged edge with a box-shadow (the left edge is jagged at all rotations that are not 45deg increments)
The :before and :after pseudo elements are given z-index: 1
Elements that will sit above the "background" will need position: relative and z-index: 2 to push them above it. (Like the paragraph in the example below)
Example 1
body {
background: linear-gradient(#000 0%, #FFF 100%) no-repeat;
}
div {
position: relative;
width: 500px;
height: 350px;
overflow: hidden;
padding-left: 100px;
}
div:before,
div:after {
content: '';
display: block;
position: absolute;
height: 200%;
width: 200%;
top: -220px;
left: 90px;
background: radial-gradient(circle closest-corner at 20% 50%, #33753E 0%, #003832 100%);
transform: rotate(-15deg);
z-index: 1;
}
div:after {
top: -220px;
left: 92px;
box-shadow: 0 0 2px 2px #003832;
}
p {
color: #FFF;
z-index: 2;
position: relative;
}
<div>
<p>This is some text</p>
</div>
Example 2 - extended
body {
background: linear-gradient(#000 0%, #FFF 100%) no-repeat;
margin: 0;
}
div {
position: relative;
height: 350px;
overflow: hidden;
padding-left: 100px;
max-width: 1600px;
}
div:before,
div:after {
content: '';
display: block;
position: absolute;
height: 300%;
width: 300%;
top: -200%;
left: 90px;
background: radial-gradient(circle closest-corner at 20% 50%, #33753E 0%, #003832 100%);
transform: rotate(-15deg);
z-index: 1;
}
div:after {
left: 92px;
box-shadow: 0 0 2px 2px #003832;
}
p {
color: #FFF;
z-index: 2;
position: relative;
left: 80px;
}
<div>
<p>This is some text</p>
</div>
If you want it to be exactly as you shown on a picture - try :before pseudoclass.
#div_with_background{
position: relative;
background: radial-gradient(circle closest-corner at 60% 50%, #33753E 0%, #003832 100%);
width: 567px;
height: 356px;
}
#div_with_background:before{
content: "";
position: absolute;
top: 0px;
left: 0px;
width: 0;
height: 0;
border-style: solid;
border-width: 356px 0 0px 130px;
border-color: transparent transparent transparent #FFFFFF;
z-index: 1;
}
<div id="div_with_background"></div>