Neighboring skewed divs leave 1px gap between them - html

I have two skewed divs with linear gradient backgrounds, which should be lining up perfectly, yet they leave a 1px gap between them.
This fiddle demonstrates the problem: https://jsfiddle.net/jesperryom/rn1ncd5u/
I have seen two suggested solutions (moving one div 1px to compensate, or giving them a transparent border), but none of those seem to work when the background color of the divs is a linear gradient as this image shows:
Left has div moved 1px, right has transparent borders
Any ideas?
HTML
<div id="top"></div>
<div id="left"></div>
CSS
#top {
position: absolute;
top: 50px;
left: 50px;
width: 200px;
height: 50px;
background: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5) 60%, rgba(0, 0, 0, 0));
transform-origin: left top;
transform: skew(45deg);
}
#left {
position: absolute;
top: 50px;
left: 50px;
width: 50px;
height: 200px;
background: linear-gradient(to right, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5) 60%, rgba(0, 0, 0, 0));
transform-origin: left top;
transform: skewY(45deg);
}

Box shadow are way harder to manage, but don't have that problem
#top {
position: absolute;
top: 50px;
left: 50px;
width: 200px;
height: 50px;
transform-origin: left top;
transform: skew(45deg);
box-shadow: inset -22px 45px 80px -18px black;
}
#left {
position: absolute;
top: 50px;
left: 50px;
width: 50px;
height: 200px;
transform-origin: left top;
transform: skewY(45deg);
box-shadow: inset 45px -22px 80px -18px black;
}
<div id="top"></div>
<div id="left"></div>

Related

Create semi-circular border CSS

I want to make a card look like this, the border or the sides of the card are semi-circular, is it possible to make it with css? if yes, how? Thank you in advance
.wrapper {
}
.content-card {
width: 315px;
height: 131px;
left: 0px;
top: 0px;
background: #FFFFFF;
box-shadow: 4px 8px 12px rgba(0, 0, 0, 0.12);
border-radius: 8px;
}
<div class="wrapper">
<div class="content-card">
</div>
</div>
Multiple background can do it:
.content-card {
width: 300px;
height: 150px;
background:
radial-gradient(8px at left ,#0000 98%,#fff) left ,
radial-gradient(8px at right,#0000 98%,#fff) right;
background-size: 50.5% 25px;
background-repeat:repeat-y;
filter: drop-shadow(4px 8px 12px rgba(0, 0, 0, 0.12));
border-radius: 8px;
}
body {
background: pink;
}
<div class="content-card">
</div>
The old way - border-image
It permits you to use the willing image for borders, it was widely use for this kind of cases. You can have repeat option on it to allow different box's sizes with the same style.
The mozilla doc is quite explicit with good examples of it : https://developer.mozilla.org/en-US/docs/Web/CSS/border-image
The recent way - without image
You have the possibility to use pseudo-element :after and :before and stylize those elements with a repeated background using radial-gradient.
body {
background-color: #ffaaaa;
}
.ticket {
position: relative;
width: 300px;
height: 170px;
margin: 10px;
border-radius: 10px;
background: white;
box-shadow: 4px 8px 12px rgba(0, 0, 0, 0.12);
}
.ticket:before,
.ticket:after {
content: '';
position: absolute;
top: 5px;
width: 6px;
height: 160px;
}
.ticket:before {
left: -5px;
background: radial-gradient(circle, transparent, transparent 50%, #FBFBFB 50%, #FBFBFB 100%) -7px -8px/16px 16px repeat-y;
}
.ticket:after {
left: 300px;
background: radial-gradient(circle, transparent, transparent 50%, #FBFBFB 0%, #FBFBFB 100% ) -3px -7px / 16px 16px repeat-y;
}
<div class="ticket"></div>

How change the shape of div corners?

I am trying to achieve this shape of div to hold profile information.
So far I've curved one of the corners. However, I am having problems parallel lines.
My HTML:
<div class="profile-card">
<h1>Sector Specialist</h1>
<p>Frank ocean</p>
</div>
My CSS:
.profile-card{
margin-top:150px;
float:right;
background-color: rgba(0,0,0,0.4);
height:500px;
text-align:center;
padding: 50px 40px;
border: 2px solid red;
border-top-left-radius: 39px;
}
The codepen is https://codepen.io/anon/pen/wjMQmw
Thank you in advance.
I would consider a solution with pseudo-element with some skew transformation:
.profile-card {
background: rgba(0, 0, 0, 0.4);
width: 200px;
text-align: center;
padding: 50px 0 0 40px;
border-top-left-radius: 39px;
border-left: 1px solid red;
border-top: 1px solid red;
position: relative;
}
.profile-card:before {
content: "";
position: absolute;
right: -40px;
width: 40px;
top: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.4);
transform: skewY(45deg);
transform-origin: top left;
border-top: 1px solid red;
border-right: 1px solid red;
box-sizing:border-box;
}
.profile-card:after {
content: "";
position: absolute;
bottom: -40px;
height: 40px;
right: 0;
left: 0;
background: rgba(0, 0, 0, 0.4);
transform: skewX(45deg);
border-left: 1px solid red;
border-bottom: 1px solid red;
transform-origin: top left;
box-sizing:border-box;
}
body {
background:linear-gradient(to right,lightblue,pink)
}
<div class="profile-card">
<h1>Sector Specialist</h1>
<p>Frank ocean</p>
</div>
Without the border I would consider multiple gradient to achieve the layout:
.profile-card {
background:
linear-gradient(to bottom left,rgba(0, 0, 0, 0.4) 50%,transparent 51%)0 100%/50px 50px no-repeat,
linear-gradient(to top right,rgba(0, 0, 0, 0.4) 50%,transparent 51%)100% 0/50px 50px no-repeat,
linear-gradient(rgba(0, 0, 0, 0.4),rgba(0, 0, 0, 0.4))100% 100%/calc(100% - 50px) 50px no-repeat,
linear-gradient(rgba(0, 0, 0, 0.4),rgba(0, 0, 0, 0.4))0 0/calc(100% - 50px) 50px no-repeat,
linear-gradient(rgba(0, 0, 0, 0.4),rgba(0, 0, 0, 0.4))0 50px/100% calc(100% - 100px) no-repeat;
width: 200px;
text-align: center;
padding: 50px 40px;
border-top-left-radius: 39px;
}
<div class="profile-card">
<h1>Sector Specialist</h1>
<p>Frank ocean</p>
</div>
Or the clip-path solution:
.profile-card {
background:rgba(0, 0, 0, 0.4);
width: 200px;
text-align: center;
padding: 50px 40px;
border-top-left-radius: 39px;
-webkit-clip-path: polygon(1% 0%, 75% 1%, 100% 30%, 100% 100%, 21% 100%, 0% 74%);
clip-path: polygon(1% 0%, 75% 1%, 100% 30%, 100% 100%, 21% 100%, 0% 74%)
}
<div class="profile-card">
<h1>Sector Specialist</h1>
<p>Frank ocean</p>
</div>
For super complex bordering, one option is to use SVG. Here is an example of basic usage of polygon. SVG embedded into HTML can be styled using CSS easily:
body{
margin:0;
height: 500px;
background: url('https://cdn3.tropicalsky.co.uk/images/1280x720/downtown-dubai-aerial-view.jpg');
}
.profile-card{
margin-top:5px;
background-color: transparent;
height:800px;
width: 200px;
text-align:center;
padding: 50px 40px;
position: relative;
}
.profile-card h1, .profile-card p {
position: relative;
}
.frame {
position: absolute;
top: 20px;
left: 20px;
opacity: 0.7;
}
<div class="profile-card">
<svg class="frame" height="300" width="300">
<polygon points="50 0,250 0,300 50,300 300, 50 300, 0 250, 0 50,7.5 25, 15 15, 25 7.5" style="fill:lightgrey;stroke:orange;stroke-width:1" />
</svg>
<h1>Sector Specialist</h1>
<p>Frank ocean</p>
</div>

background of div not obeying z-index property

I have a div wrapper and a div row and both have position properties set to relative. The wrapper div has a higher z-index than the inner div and both have background's set, however, the higher z-index background is still below the lower div's background. JS Fiddle Example
.wrapper {
position: relative;
z-index: 1000;
border: 1px solid black;
width: 131px;
height: 25px;
background: repeating-linear-gradient( to right, rgba(255, 0, 0, 0), rgba(255, 0, 0, 0) 10px, black 11px, black 1px);
}
.row {
position: relative;
z-index: -1;
margin-top: 2px;
margin-bottom: 1px;
width: 100%;
height: 20px;
background: linear-gradient( to right, rgba(255, 0, 0, 0) 50%, red 50%);
}
<div class="wrapper">
<div class="row"></div>
</div>
If you want the grid lines over the red bar, remove the z-index from the wrapper div:
.wrapper {
position: relative;
border: 1px solid black;
width: 131px;
height: 25px;
background: repeating-linear-gradient( to right, rgba(255, 0, 0, 0), rgba(255, 0, 0, 0) 10px, black 11px, black 1px);
}
.row {
position: relative;
z-index: -1;
margin-top: 2px;
margin-bottom: 1px;
width: 100%;
height: 20px;
background: linear-gradient( to right, rgba(255, 0, 0, 0) 50%, red 50%);
}
<div class="wrapper">
<div class="row"></div>
</div>
Remove z-index from wrapper div, and you should be good to go.
.wrapper {
position: relative;
border: 1px solid black;
width: 131px;
height: 25px;
background: repeating-linear-gradient( to right, rgba(255, 0, 0, 0), rgba(255, 0, 0, 0) 10px, black 11px, black 1px);
}
.row {
position: relative;
z-index: -1;
margin-top: 2px;
margin-bottom: 1px;
width: 100%;
height: 20px;
background: linear-gradient( to right, rgba(255, 0, 0, 0) 50%, red 50%);
}
<div class="wrapper">
<div class="row"></div>
</div>

How do I get spotlight/shadow position to remain exactly same relative horizontal center position regardless of zoom?

In the following fiddle I successfully have made the spotlight stay in the same place (horizontally centered) except for when my zoom factor is too large. In other words, when I zoom in my spot light does not stay in the center of the horizontal view port.
Please note the use of .spotlight-2:before to fill the left portion of the shadow on the viewport. This is what I needed to prevent non shaded region from appearing.
How do I make the spotlight stay in center horizontally and not shift to the right when zooming in closely in the browser?
Fiddle
https://jsfiddle.net/u0onf23y/
Resulting Output
https://jsfiddle.net/u0onf23y/embedded/result/
CSS
td .div{
height: 400px;
}
.extend-full {
padding-left: 3000px;
margin-left: -3000px;
padding-right: 3000px;
margin-right: -3000px; }
.spotlight-2{
top: 0px;
margin-left:-80px;
float: left;
display: block;
background: radial-gradient(10px 10px at 560px 400px, transparent 0, transparent 150px, rgba(0, 0, 0, 0.5) 160px);
background: -moz-radial-gradient(10px 10px at 560px 400px, transparent 0, transparent 150px, rgba(0, 0, 0, 0.5) 160px);
background: -webkit-radial-gradient(10px 10px at 560px 400px, transparent 0, transparent 150px, rgba(0, 0, 0, 0.5) 160px);
background: -o-radial-gradient(10px 10px at 560px 400px, transparent 0, transparent 150px, rgba(0, 0, 0, 0.5) 160px);
margin-left: 0px;
height: 100%;
position: fixed;
width: 100%;
min-width: 100vw;
min-height: 100vh;
z-index: 10;
};
position: absolute;
width: 100%;
z-index: 10; }
.account-settings-confirm-container-overlay {
z-index: 10;
background-color: white !important;
height: 99px;
position: absolute;
margin-top: 10px;
width: 250px;
font-size: 12px;
box-shadow: 0px 1px 1px 1px rgba(0, 0, 0, 0.1); }
.spotlight-2:before {
content: "";
position: absolute;
display: block;
left: -100%;
height: 100%;
width: 100%;
background: rgba(0,0,0,0.5);
}
Try flexbox. See example fullpage http://codepen.io/rhroyston/full/qadGgd/
html, body {
height: 100%;
margin: 0;
}
#viewport{
height:100%;
display: flex;
align-items: center;
justify-content: center;
z-index: 1;
background-color: rgb(0,0,0);
background-color: rgba(0,0,0,0.4);
}
.a{
box-shadow: 0px 0px 5px grey inset;
margin: auto;
padding: 20px;
background-color: #fefefe;
border-radius: 50%;
}
<div id="viewport">
<div class="box">
<div class="a"></div>
</div>
</div>

Create arc button as shown in the image link

arc button
i want to create an arc button like shown in the link . is it possible with css
i have tried the following code but i wanted to remove the white portion at the bottom of it so that it may look like an arc as shown in the image
thankyou
nav {
width: 400px;
height: 400px;
background: transparent;
border-radius: 50%;
padding: 20px;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
transform: rotate(45deg);
}
.button {
display: block;
width: 30%;
height: 30%;
margin: 2%;
position: relative;
float: left;
box-shadow: 1px 0px 3px 1px rgba(0, 0, 0, 0.4), inset 0 0 0 1px #FFF;
}
.button::after {
content: "";
display: block;
width: 50%;
height: 50%;
background: transparent;
position: absolute;
border-radius: inherit;
}
.button.top {
border-radius: 100% 0 0 0;
background: -webkit-radial-gradient(bottom right, ellipse cover, #fff 35%, #eee 75%);
background: radial-gradient(ellipse cover at bottom right, #ffffff 35%, #eeeeee 75%);
}
.button.top::after {
bottom: 0;
right: 0;
box-shadow: inset 2px 1px 2px 0 rgba(0, 0, 0, 0.4), 10px 10px 0 10px transparent;
-webkit-transform: skew(-3deg, -3deg) scale(0.96);
-moz-transform: skew(-3deg, -3deg) scale(0.96);
transform: skew(-3deg, -3deg) scale(0.96);
}
<nav>
<a class="button top" href="#"><i class="icon-play"></i></a>
</nav>