Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm trying to create a circle with CSS, which looks exactly like on the following picture:
How to make this with CSS?
The simplest way I can think to achieve this is to use border-radius on a grey div to make the circle and to apply black borders to two adjacent sides. You can then simply rotate the element so that the borders are on the top.
div.circleThing {
width:100px; height:100px;
background:#666;
border:10px solid black;
border-radius:50%;
border-bottom-color:#fff;
border-right-color:#fff;
transform: rotate(45deg);
}
<div class="circleThing"></div>
Another possible alternative if you do not want to rotate the element is to use a pseudo-element which is placed behind its parent.
Then add a linear gradient background with a cutoff to white and then you get your desired effect.
This does require a little more CSS and is a little more difficult but you get the plus side of not having rotated elements.
.circle {
width: 130px;
height: 130px;
background: grey;
margin: 10px;
border-radius: 50%;
position: relative;
}
.circle:before {
content: '';
position: absolute;
z-index: -1;
width: 150px;
height: 150px;
display: block;
margin: -10px;
background: linear-gradient(to top, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 1) 50%, rgba(0, 0, 0, 1) 51%, rgba(0, 0, 0, 1) 100%);
border-radius: 50%;
}
<div class="circle"></div>
Related
This question already has answers here:
Weird effect when applying transparent border over an element with a gradient background
(7 answers)
Closed 25 days ago.
What is the reason for the defect in which the background color is superimposed on the border in top side and in 1 case goes beyond in bottom side?
.scaledSquare{
position: absolute;
left: 50px;
top: 50px;
height: 97px;
width: 97px;
border: none;
background: linear-gradient(315deg, #2D8FDF 75%, #2D8FDF12 76%, #2D8FDF12 100%);
border-radius: 12px;
border: 1px solid #FFFFFF12;
box-sizing: border-box;
transform: rotate(45deg);
}
.scaledSquare1{
left: 190px;
top: 190px;
background: linear-gradient(315deg, #2D8FDF 45%, #2D8FDF12 45%, #2D8FDF12 100%);
}
<div class="scaledSquare"></div>
<div class="scaledSquare1 scaledSquare"></div>
The reason you are getting the clipping artefacts is most likely due to your background being smaller than the border box. Setting the background-origin to border-box on both elements should fix the issue.
First of all I know that this question has been asked before (3 years ago) here, but I couldn't find a proper solution so I'm trying again.
I'm trying to implement the following design:
I'm referring to this overlay which seems like it is missing a part.
My idea was setting a background image (first div), then cover it with this gradient-background overlay (second div), and then somehow subtracting from this overlay this rotated shape (third div).
being naive I thought that somehow I'll find a way to implement this subtraction operation, but here I'm after two days of trying.
I've read a lot about masking, but couldn't find a way of properly using it.
So my questions are:
This subtraction approach is the proper approach here? If it is, how can I achieve it? and If not? what other solution can you offer?
Thanks a lot!
Evyatar
example with mix-blend-mode before it get closed : (answered for the fun to play with mix-blend-mode)
html {
background: linear-gradient(90deg, rgb(165, 192, 253), rgb(247, 128, 132));
padding: 2em;
height: 100%;
}
body {
width: 900px;
margin: auto;
background: linear-gradient(to bottom, rgba(255, 255, 255, 0.25) 50px, rgba(255, 255, 255, 1) 500px), url(https://www.bing.com/th?id=OIP.VYbZz4O-gR8sw8sRHAvh-gHaEK&pid=Api&rs=1 ) no-repeat white;
height: 100%;
min-height: 800px;
background-size: 100% auto;
position: relative;
}
body:after,
body:before {
content: '';
border-radius: 15%;
width: 75%;
padding-top: 75%;
background: #ccc;
position: absolute;
right: 0;
transform: rotate(45deg) translate(-10%, -50%);
mix-blend-mode: overlay;
z-index: -1;
}
body:after {
z-index: 1;
background: #000
}
This question already has answers here:
CSS Zigzag Border with a Textured Background
(4 answers)
Closed 6 years ago.
I am trying to get this effect along the baseline of my header element.
What is the best way to go about it? Is there any way to do it without images (maybe SVG)?
A way I reckon this could be accomplished pretty nicely is using a repeat-x background image of a white square on an absolutely positioned pseudo element. However, that uses images and I'd love to be able to avoid that.
Here is solution. It's called zig-zag border.
http://jsfiddle.net/justinmc/QqnD3/
<div class="container">
<h1>Content Here</h1>
</div>
.container {
position: relative;
padding: 8px 8px 32px 8px;
background: #dddccf;
}
.container:after {
background: linear-gradient(-45deg, #ffffff 16px, transparent 0), linear-gradient(45deg, #ffffff 16px, transparent 0);
background-position: left-bottom;
background-repeat: repeat-x;
background-size: 32px 32px;
content: " ";
display: block;
position: absolute;
bottom: 0px;
left: 0px;
width: 100%;
height: 32px;
}
credits
https://cocreate.localmotors.com/blog/post/zig-zag-borders-in-css/1205/
I am trying to convert PSD into HTML using CSS.
I have a plain rectangle like this :
Now a oval shape glow element : ( As in PSD )
Because of this if you look at only rectangle , With a glow at top it looks like below :
How to achieve the same ? Any lead is appreciated :)
Using Radial Gradients:
You can sort of achieve that by placing a radial-gradient image on top of your rectangle with the solid color. The positioning and size of the gradient may need to be modified to suit your needs.
The radial-gradient that I had used is very similar to the one in your PSD image. That is is starts from a bluish color and then gradually moves to transparent. This gradient is then positioned such that its center point is at 75% width of the parent and a distance that is 25% of the parent's height above it.
div {
height: 200px;
width: 400px;
background-color: rgb(17, 45, 67);
background-image: radial-gradient(ellipse at 75% -25%, rgb(14, 102, 150) 0%, transparent 50%);
background-size: 100% 100%;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
<div></div>
The main thing to worry with using radial-gradient is the relatively poor browser support.
Using Box Shadow:
Below is a slightly different approach using a pseudo-element and box-shadow. The box-shadow has a very high spread radius which produces a glow like effect.
This has better browser support than radial-gradient (even as low as IE8) but box-shadow cannot take values in percentage and hence this solution wouldn't be very useful for dynamic sized containers.
div {
position: relative;
width: 1280px;
height: 480px;
background-color: rgb(17, 45, 67);
overflow: hidden;
}
div:after {
position: absolute;
content: '';
right: 150px;
top: -250px;
height: 250px;
width: 300px;
border-radius: 50%;
background: rgb(14, 102, 150);
box-shadow: 25px 25px 150px 250px rgba(14, 102, 150, 0.5);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
<div></div>
The only way I can see is to use a pseudo element and put a gradient background on it. I've made this quickly to show you but it does not reproduce exactly your image :
.rectangle {
position: relative;
width: 300px;
height: 100px;
background-color: #112D43;
}
.rectangle:after {
content: "";
display: block;
position: absolute;
top: 0;
right: 0;
width: 100px;
height: 40px;
background: radial-gradient(ellipse at center, #094567 0%, rgba(0, 0, 0, 0) 50%);
}
<div class="rectangle"></div>
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I need to reproduce the image below.
The image in the center is my background. In my first div I've got some text. Over this div I need maybe an other div that hides a part of the div with the text so I can see the background of my page. Is there anyway I can have this invisible square in the middle of my div in CSS ?
The reason I need this behaviour is because I'm using the parallax scrolling effect.
Only in webkit, you can use a mask:
#background, #overlay {
position: absolute;
width: 200px;
height: 400px;
}
#background {
background: url("yourimage");
}
#overlay {
top: 0px;
left: 0px;
-webkit-mask-position: 0px 0px;
-webkit-mask-size: 100% 100%;
-webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 1) 33%, rgba(0, 0, 0, 0) 33%, rgba(0, 0, 0, 0) 66%, rgba(0, 0, 0, 1) 66%),
linear-gradient(90deg, rgba(0, 0, 0, 1) 33%, rgba(0, 0, 0, 0) 34%, rgba(0, 0, 0, 0) 66%, rgba(0, 0, 0, 1) 66%);
background-color: rgba(255, 255, 255, 0.8);
}
fiddle
I have set the background of the overlay with a little alpha to show that the background div is stiil there, just set it to white in real code.
position:absolute; left: something; top: something; z-index: 2;
I would suggest you use a transparent image for this. This will create a 'window' to expose your background. I will also enable your text to wrap around it as apposed to cover it.
Like this:
#text-container {
width: 500px;
height: 500px;
position: relative;
z-index: 0;
overflow: hidden;
}
#image-container {
width: 200px;
height: 100px;
position: absolute;
left: 50%;
top: 50%;
margin-left: -100px;
margin-top: -50px;
background-color: #aaa;
z-index: 5;
}
And the HTML:
<div id="text-container">
<p>Background text here</p>
<div id="image-container">
<img src="picture.jpg" />
</div>
</div>
The reason for specifying the top and left at 50% is so that the image box will be 50% from the top and left of the parent div. This applies to the top and left edges of the image box though, so it ends up not being quite centered. Setting the margins to - 1/2 the width and hight offsets them so that the box is properly centered.
Here is a link to a working fiddle
I think the best you can do in pure CSS is to place an image on top of your text which exactly matches your background image. It would not be a true hole, just an illusion.