Please help me change the cutout from .top so that it is on top and not on the right.
As shown in the image.
Thank you very much in advance.
I really hope for your help, I'm new to this business.
Source code: Source code
.box {
margin-top:120px;
width:200px;
height:100px;
background:white;
}
.box .top {
height:100px;
width:150px;
transform:translateY(-100%);
position:relative;
background:#fff;
}
.top:before,
.top:after{
content:"";
position:absolute;
top:0;
width:50px;
left:100%;
bottom:50%;
background:
radial-gradient(100% 50% at top left, #fff 98%,transparent 100%) right,
radial-gradient(100% 50% at bottom right, transparent 98%,#fff 100%) left;
background-size:50% 100%;
background-repeat:no-repeat;
}
.top:after {
transform-origin:bottom;
transform:scaleY(-1);
}
body {
background:pink;
}
<div class="box">
<div class="top"></div>
</div>
You can adjust your code like below:
.box {
margin-top:90px; /* make it at lealst the same as the height of the pseudo element */
width:200px;
height:100px;
background:white;
position:relative;
}
.box:before,
.box:after{
content:"";
position:absolute;
bottom:100%;
width:50%;
left:0;
height:80px; /* adjust this to control the height */
background:
radial-gradient(50% 100% at bottom left, #fff 98%,#0000) top,
radial-gradient(50% 100% at top right , #0000 98%,#fff) bottom;
background-size:100% 50%;
background-repeat:no-repeat;
}
.box:after {
transform-origin:right;
transform:scaleX(-1);
}
body {
background:pink;
}
<div class="box">
</div>
Related
Please help me change the cutout from .top so that it is on top and not on the right.
As shown in the image.
Thank you very much in advance.
I really hope for your help, I'm new to this business.
Source code: Source code
.box {
margin-top:120px;
width:200px;
height:100px;
background:white;
}
.box .top {
height:100px;
width:150px;
transform:translateY(-100%);
position:relative;
background:#fff;
}
.top:before,
.top:after{
content:"";
position:absolute;
top:0;
width:50px;
left:100%;
bottom:50%;
background:
radial-gradient(100% 50% at top left, #fff 98%,transparent 100%) right,
radial-gradient(100% 50% at bottom right, transparent 98%,#fff 100%) left;
background-size:50% 100%;
background-repeat:no-repeat;
}
.top:after {
transform-origin:bottom;
transform:scaleY(-1);
}
body {
background:pink;
}
<div class="box">
<div class="top"></div>
</div>
You can adjust your code like below:
.box {
margin-top:90px; /* make it at lealst the same as the height of the pseudo element */
width:200px;
height:100px;
background:white;
position:relative;
}
.box:before,
.box:after{
content:"";
position:absolute;
bottom:100%;
width:50%;
left:0;
height:80px; /* adjust this to control the height */
background:
radial-gradient(50% 100% at bottom left, #fff 98%,#0000) top,
radial-gradient(50% 100% at top right , #0000 98%,#fff) bottom;
background-size:100% 50%;
background-repeat:no-repeat;
}
.box:after {
transform-origin:right;
transform:scaleX(-1);
}
body {
background:pink;
}
<div class="box">
</div>
I am trying to achieve a cut off border on two points of the browser. top left and top right. I am trying to get the black borders not to scale. Meaning the parts always remain the same width / height while also leaving the extra 7% vh at the bottom. currently I am using a clip-path. Im trying to do this without using svg Thanks!
body {
margin: 0;
padding: 0;
}
.section2 {
background: white;
height: 100vh;
width: 100vw;
clip-path: polygon(1px 9px, 99% 1px, 100% 99%, 1% 100%);
}
.section1 {
background: black;
height: 93vh;
width: 100vw;
}
header {
padding: 10px;
}
<div class="section1">
<div class="section2">
<header>
Zebra
</header>
</div>
</div>
You can try mulitple background like below:
.box {
margin:10px;
height:300px;
background:
linear-gradient(to top left,transparent 47%,#000 50%) top /100% 10px,
linear-gradient(to bottom left,transparent 47%,#000 50%) left /10px 100%,
linear-gradient(to top right,transparent 47%,#000 50%) right /10px 100%;
background-repeat:no-repeat;
padding:10px;
}
<div class="box"> some text </div>
With clip-path it can be done like below
.box {
margin:10px;
height:300px;
padding:10px;
position:relative;
z-index:0;
}
.box::before {
content:"";
position:absolute;
z-index:-1;
top:0;
left:0;
right:0;
bottom:0;
border:10px solid #000;
clip-path:polygon(0 0,100% 0,100% 100%,calc(100% - 10px) 1px,1px 10px,10px 100%, 0 100%);
}
<div class="box"> some text </div>
I have a box with 3 triangles inside.
The 3 triangles should be a link, but they are clickable boxes and not triangles, so if you click on one image it depends which link is the destination.
If you click on the left image the destination should be link 1 but it is link3 because of the box from the bottom-pic.
The position of the elements is good. But the link should be the same size like the images and not just a box with the same width and height.
I have tried overflow:hidden and z-index, but it didnt worked.
<style>
#card{
width:472px;
height:472px;
display:grid;
grid-template-columns:50% 50%;
}
#l3{
position:relative;
bottom:149px;
}
</style>
<div id="card">
<a href="link1.html" >
<img src="img/left.png">
</a>
<a href="link2.html">
<img src="img/right.png">
</a>
<a href="link3.html" id="l3">
<img src="img/bottom.png">
</a>
</div>
I want the anchor link being the same size as the image.
Or the image being an real triangle and not a box.
Thank you, and if you have questions feel free to ask.
Screenshot of Card:
https://www.directupload.net/file/d/5488/ap538p4i_png.htm
You can consider clip-path to do this if you want to restrict the mouse events to only the visible area:
.box {
width:200px;
height:250px;
position:relative;
}
.box > a {
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
background-size:cover;
background-position:center;
}
.box > a:nth-child(1) {
-webkit-clip-path:polygon(0 0,50% 0, 50% 50%, 0 70%);
clip-path:polygon(0 0,50% 0, 50% 50%, 0 70%);
}
.box > a:nth-child(2) {
-webkit-clip-path:polygon(100% 0,50% 0, 50% 50%, 100% 70%);
clip-path:polygon(100% 0,50% 0, 50% 50%, 100% 70%);
}
.box > a:nth-child(3) {
-webkit-clip-path:polygon(0 100%,0 70%, 50% 50%, 100% 70%,100% 100%);
clip-path:polygon(0 100%,0 70%, 50% 50%, 100% 70%,100% 100%);
}
.box > a:hover {
filter:grayscale(100%);
}
<div class="box">
<a href="#" style="background-image:url(https://picsum.photos/id/1/800/400)" ></a>
<a href="#" style="background-image:url(https://picsum.photos/id/10/800/400)" ></a>
</div>
A simplified version where you need clip-path with only one element:
.box {
width:200px;
height:250px;
position:relative;
}
.box > a {
position:absolute;
background-size:cover;
background-position:center;
}
.box > a:nth-child(1) {
top:0;
left:0;
right:50%;
bottom:30%;
}
.box > a:nth-child(2) {
top:0;
right:0;
left:50%;
bottom:30%;
}
.box > a:nth-child(3) {
top:50%;
left:0;
right:0;
bottom:0;
clip-path:polygon(0 100%,0 30%, 50% 0%, 100% 30%,100% 100%);
}
.box > a:hover {
filter:grayscale(100%);
}
<div class="box">
<a href="#" style="background-image:url(https://picsum.photos/id/1/800/400)" ></a>
<a href="#" style="background-image:url(https://picsum.photos/id/10/800/400)" ></a>
</div>
Another idea without clip-path:
.box {
width:200px;
height:250px;
position:relative;
z-index:0;
overflow:hidden;
}
.box > a {
position:absolute;
background-size:cover;
background-position:center;
overflow:hidden;
}
.box > a:nth-child(1) {
top:0;
left:0;
right:50%;
bottom:30%;
background-size:0;
transform: skewY(-20deg);
transform-origin: left;
}
.box > a:nth-child(2) {
top:0;
right:0;
left:50%;
bottom:30%;
background-size:0;
transform: skewY(20deg);
transform-origin: right;
}
.box > a:nth-child(1):before,
.box > a:nth-child(2):before{
content:"";
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
background-image:inherit;
background-size:cover;
background-position:inherit;
transform-origin: inherit;
}
.box > a:nth-child(1):before {
transform: skewY(20deg);
}
.box > a:nth-child(2):before {
transform: skewY(-20deg);
}
.box > a:nth-child(3) {
top:50%;
left:0;
right:0;
bottom:0;
z-index:-1;
}
.box > a:hover {
filter:grayscale(100%);
}
<div class="box">
<a href="#" style="background-image:url(https://picsum.photos/id/1/800/400)" ></a>
<a href="#" style="background-image:url(https://picsum.photos/id/10/800/400)" ></a>
</div>
I believe the issue is that your links aren't set to
a {
display:block;
}
Here is a fiddle with 2 divs wrapped in tags. One has the link set to display block, the other doesn't.
https://jsfiddle.net/L6w3n28u/1/
Use inspect element and you'll see the one set to display block fully covers the area that the div inside it occupies (in your case this would be your triangle image).
How can I make this line(see picture) with CSS?
Using pseudo element as :after
div{
height:80px;
width:3px;
background:black;
border-radius: 23%;
position:relative;
}
div:after{
content:'';
height:3px;
width:170px;
background:black;
border-radius: 23%;
position:absolute;
top:47%;
}
<div></div>
No need complex code, one element and few CSS lines are enough:
.line {
width:200px;
height:100px;
border-left:5px solid;
background:linear-gradient(#000,#000) center/100% 5px no-repeat;
}
<div class="line">
</div>
Or like this:
.line {
width:200px;
height:100px;
padding:48px 0;
box-sizing:border-box;
border-left:5px solid;
background:#000 content-box;
}
<div class="line">
</div>
.line1 {
height:150px;
width:3px;
background:#000;
position:relative;
}
.line2 {
height:5px;
width:300px;
background:#000;
position:absolute;
/* following 2 code is excellent center for second line. */
top:50%;
transform:translateY(-50%);
}
<div class="line1">
<div class="line2"></div>
</div>
I want this: http://gyazo.com/0fe69e349ed5cd4e72a08ed8e60af5d4
But I can't manage to achieve it.
I can not change the image.
I have used an image as a mask, but that gives me this: http://gyazo.com/b69e840d095212bce422252cec081fe9
Is there a way to make the side parts white aswell?
My code:
#section1{
height:275px;
width:100%;
background-image: url('/img/paral1.jpg');
background-position: center top;
background-repeat:no-repeat;
background-size: 100% 916px;
}
.overlay{
position: absolute;
margin-top:180px;
height:100px;
width:100%;
overflow: hidden;
}
.mask{
margin: 0 auto;
background-image: url('/img/section1.png');
height:100px;
width:1080px;
background-size:100% 100%;
}
edit: JSfiddle: http://jsfiddle.net/31kxqmLt/
JSfiddle in fullscreen: http://jsfiddle.net/31kxqmLt/embedded/result/
edit edit: The mask must have a width of 1080px and the rest of the space should be white.
I made this Html/css example of the shape you are trying to make.
It uses background image, pseudo elements and skewX to give the transparent cut out effect on bottom left and bottom right. It also is responsive :
DEMO
output :
.wrap {
width:100%;
padding-bottom:30%;
position:relative;
}
.wrap:before {
content:'';
background-image: url(http://i.imgur.com/ug3M32a.jpg);
background-size:100% auto;
position:absolute;
width:100%;
left:0;
height:50%;
}
.b{
position:absolute;
bottom:0;
width:50%; height:50%;
}
.l{
left:5%;
transform-origin: 0 0;
transform: skewX(45deg);
overflow:hidden;
border-bottom-left-radius:3%;
}
.r{
right:5%;
transform-origin: 100% 0;
transform: skewX(-45deg);
overflow:hidden;
border-bottom-right-radius:3%;
}
.l:before, .r:before{
content:'';
display:block;
width:100%; height:100%;
background-size: 200%;
background-image: url(http://i.imgur.com/ug3M32a.jpg);
}
.l:before{
background-position: 10% -100%;
transform-origin: 0 0;
transform: skewX(-45deg);
}
.r:before{
background-position: 90% -100%;
transform-origin: 100% 0;
transform: skewX(45deg);
}
body {
padding:20px 10%;
background-image : url(http://i.imgur.com/k8BtMvj.jpg);
background-size:cover;
}
<div class="wrap">
<div class="b l"></div>
<div class="b r"></div>
</div>
Js fiddle
full screen
Js fiddle
edited the mask image
set mask width to 100% so that it fits in all the resolutions
.mask{
margin: 0 auto;
background: url('http://s29.postimg.org/5g7z03ypz/image.png') no-repeat bottom;
height:100px;
width:100%;
background-size:100% auto;
}
for smaller resolution min-width 300
#section1{
max-height:200px;
min-height:30%;
overflow:hidden;
position:relative;
}
JS Fiddle