I'm creating a down arrow for the bottom of a full width div, which works great in the one instance below (where a coloured section runs into a white section):
But not for this instance...
The situation above has a blue div with a down arrow going into a full width background image. As you can see it doesn't quite work.
I want the tip of the arrow to lay over the top of the image... or another colour. How can I do that?
Here's my setup:
<div class="bannerStripHeader" style="background-color:#009edb;">
<section class="row">
<div class="columns large-12" style="color:inherit !important;">
<div class="brandHeaderContent">
Content here
</div>
</div>
</section>
</div>
I'm using the border colour to set it to white.
.bannerStripHeader:before {
border-width: 50px 0 30px 70vw;
border-color: transparent transparent transparent #fff;
left: -5px;
-webkit-transform: rotateZ(0deg);
transform: rotateZ(0deg);
-webkit-transform-origin: 100% 50%;
-ms-transform-origin: 100% 50%;
transform-origin: 100% 50%;
}
.bannerStripHeader:after {
border-width: 50px 70vw 30px 0;
border-color: transparent #fff transparent transparent;
right: -5px;
-webkit-transform: rotateZ(0deg);
transform: rotateZ(0deg);
-webkit-transform-origin: 0 50%;
-ms-transform-origin: 0 50%;
transform-origin: 0 50%;
}
.bannerStripHeader:after,
.bannerStripHeader:before {
content: "";
border-style: solid;
bottom: -23px;
height: 0;
-webkit-transition: -webkit-transform .5s ease .5s;
transition: transform .5s ease .5s;
width: 0;
position: absolute;
}
The description and the code you provided don't really match well so I'm not quite sure what you're asking. Are you trying to achieve something like this demo?
.bannerStripHeader {
position: absolute;
overflow: hidden;
}
.bannerStripHeader:before {
border-width: 50px 50vw 0 50vw;
border-color: #009edb transparent transparent transparent;
left: 50%;
transform: translate(-50%, 0);
top: 0;
width: 0;
height: 0;
display: block;
content: "";
border-style: solid;
position: absolute;
}
/* only for demo */
img {
width: 100%;
}
<div class="bannerStripHeader">
<section class="row">
<div class="columns large-12">
<div class="brandHeaderContent">
<img src="https://images.unsplash.com/photo-1427477321886-abc24e8ce923?dpr=1&auto=compress,format&fit=crop&w=1199&h=800&q=80&cs=tinysrgb&crop=">
</div>
</div>
</section>
</div>
Related
I have the following gold dividing line I'm trying to create in pure CSS.
I'm trying to create this with the transform:scale; CSS So far I have found the following:
.border_angle {
border: 50vw solid transparent;
width: 0;
height: 0;
border-bottom-color: transparent;
border-left-color: transparent;
border-top-color: transparent;
transform: scaleY(0.105) translateY(-50%);
-webkit-transform: scaleY(0.105) translateY(-50%);
-o-transform: scaleY(0.105) translateY(-50%);
-moz-transform: scaleY(0.105) translateY(-50%);
-ms-transform: scaleY(0.105) translateY(-50%);
position: absolute;
transform-origin: top center;
top: 0;
left: 0;
right: 0;
z-index: 11;
}
.border_angle_gold_l {
border-left-color: #BE955A;
}
.border_angle_gold-light_r {
border-right-color: #CCA56B;
}
<div style="margin-top: 200px;" class="border_angle border_angle_gold_l border_angle_gold-light_r"></div>
Essentially, I nearly have it but I just need to reverse the triangles!! I can't figure out how... Any help would be massively appreciated.
I would do this differently with less of code and linear-gradient:
.triangle {
margin-top:100px;
height:80px;
background-image:
linear-gradient(to bottom right, transparent 50%,#BE955A 51%),
linear-gradient(to top right, transparent 50%,#BE955A 51%),
linear-gradient(to bottom left, transparent 50%,#CCA56B 51%),
linear-gradient(to top left, transparent 50%,#CCA56B 51%);
background-position:0 0,0 100%,100% 0,100% 100%;
background-size:50.3% 50%;
background-repeat:no-repeat;
}
<div class="triangle">
</div>
Here is another idea using clip-path:
.triangle {
margin-top: 100px;
height: 80px;
background: linear-gradient(to left, #CCA56B 50%, #BE955A 0);
-webkit-clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}
<div class="triangle">
</div>
You could try duplicating the div and then adding translateX like:
.border_angle {
border: 50vw solid transparent;
width: 0;
height: 0;
border-bottom-color: transparent;
border-left-color: transparent;
border-top-color: transparent;
position: absolute;
transform-origin: top center;
top: 0;
left: 0;
right: 0;
z-index: 11;
}
.border_angle_gold_l {
border-left-color: #BE955A;
}
.border_angle_gold-light_r {
border-right-color: #CCA56B;
}
.first {
transform: scaleY(0.105) translateY(-50%) translateX(50%);
-webkit-transform: scaleY(0.105) translateY(-50%) translateX(50%);
-o-transform: scaleY(0.105) translateY(-50%) translateX(50%);
-moz-transform: scaleY(0.105) translateY(-50%) translateX(50%);
-ms-transform: scaleY(0.105) translateY(-50%) translateX(50%);
}
.second {
transform: scaleY(0.105) translateY(-50%) translateX(-50%);
-webkit-transform: scaleY(0.105) translateY(-50%) translateX(-50%);
-o-transform: scaleY(0.105) translateY(-50%) translateX(-50%);
-moz-transform: scaleY(0.105) translateY(-50%) translateX(-50%);
-ms-transform: scaleY(0.105) translateY(-50%) translateX(-50%);
}
<div style="margin-top: 200px;" class="border_angle border_angle_gold_l border_angle_gold-light_r first"></div>
<div style="margin-top: 200px;" class="border_angle border_angle_gold_l border_angle_gold-light_r second"></div>
Just to complete the other good answers:
The pseudo element / border approach
You can create the triangles with the help of borders and apply it to the pseudo elements ::before and ::after of your divider. This reduces your code, you only need one element in your markup and you don't have to use transformations:
.divider {
position: relative;
width: 500px;
}
.divider::before,
.divider::after {
content: '';
position: absolute;
width: 0;
height: 0;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
}
.divider::before {
border-right: 250px solid #bf9655;
left: 0;
}
.divider::after {
border-left: 250px solid #cda667;
right: 0;
}
<div class="divider"></div>
The SVG approach
As SVG is widely supported now, it is also reasonable to use SVG to create shapes. Here would be a simple example, reducing the code length to a minimum of 141B:
<svg viewbox="0 0 24 2">
<polygon points="0,1 12,0 12,2" style="fill:#bf9655;" />
<polygon points="12,0 24,1 12,2" style="fill:#cda667;" />
</svg>
I am having quite a hard time trying to get a folded corner spread over the entire surface of my panel.
I don't want to set up a specific size for the folded corner as I want it to cover the entire surface, whatever the size of the panel (as it would show on mobile, tablet or desktop.
I can't figure out an easy solution to achieve this.
Here is my code :
.panel-default1 {
padding-top: 10px;
border-radius: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.10);
height: 400px;
width: 100%;
overflow: hidden;
margin: 0 auto;
position: relative;
}
.amg-corner-button_wrap {
display: block;
position: absolute;
bottom: 0;
right: 0;
width: 40px;
height: 40px;
}
.amg-corner-button_wrap:hover {
width: 120px;
height: 120px;
}
.amg-corner-button_wrap:hover div {
width: 120px;
height: 120px;
}
.amg-corner-button {
display: block;
position: absolute;
bottom: 0;
right: 0;
width: 40px;
height: 40px;
background-color: #46982b;
-webkit-transition: width 300ms, height 300ms;
-moz-transition: width 300ms, height 300ms;
-ms-transition: width 300ms, height 300ms;
-o-transition: width 300ms, height 300ms;
-webkit-transform: translateZ(0);
-moz-transform: translateZ(0);
-ms-transform: translateZ(0);
-o-transform: translateZ(0);
}
.amg-corner-button:before {
content: "";
position: absolute;
top: 0;
right: 0;
border-width: 0 0 120px 120px;
border-style: solid;
border-color: #46982b #fff;
}
.amg-corner-button_text {
font-size: 14px;
font-size: 1.4rem;
width: 120px;
position: absolute;
top: 60px;
right: 0;
left: 0;
-webkit-transform-origin: center top;
-moz-transform-origin: center top;
-ms-transform-origin: center top;
transform-origin: center top;
-webkit-transform-origin: center top center;
-moz-transform-origin: center top center;
-ms-transform-origin: center top center;
-o-transform-origin: center top center;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
text-align: center;
color: #ffffff;
}
<div class="panel panel-default1">
<div class="panel-body">
<div class='amg-corner-button_wrap'>
<div class='amg-corner-button'></div>
<span class='amg-corner-button_text'>Text Goes Here</span>
</div>
</div>
<!-- panel body -->
</div>
<!-- panel default -->
Any help on this would be very much appreciated.
Try using this as your css instead.
.panel-default1 {
padding-top: 10px;
border-radius: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.10);
height: 400px;
width: 100%;
overflow: hidden;
margin: 0 auto;
position: relative;
}
.amg-corner-button_wrap {
display: block;
position: absolute;
bottom: 0;
right: 0;
width: 40px;
height: 40px;
}
.amg-corner-button_wrap:hover {
width: 100%;
height: 100%;
}
.amg-corner-button_wrap:hover div {
width: 100%;
height: 100%;
}
.amg-corner-button {
display: block;
position: absolute;
bottom: 0;
right: 0;
width: 40px;
height: 40px;
background-color: #46982b;
-webkit-transition: width 300ms, height 300ms;
-moz-transition: width 300ms, height 300ms;
-ms-transition: width 300ms, height 300ms;
-o-transition: width 300ms, height 300ms;
-webkit-transform: translateZ(0);
-moz-transform: translateZ(0);
-ms-transform: translateZ(0);
-o-transform: translateZ(0);
}
.amg-corner-button:before {
content: "";
position: absolute;
top: 0;
right: 0;
border-width: 0 0 120px 120px;
border-style: solid;
border-color: #46982b #fff;
}
.amg-corner-button:hover::before {
border-width: 0;
}
.amg-corner-button_text {
font-size: 14px;
font-size: 1.4rem;
width: 120px;
position: absolute;
top: 60px;
right: 0;
left: 0;
-webkit-transform-origin: center top;
-moz-transform-origin: center top;
-ms-transform-origin: center top;
transform-origin: center top;
-webkit-transform-origin: center top center;
-moz-transform-origin: center top center;
-ms-transform-origin: center top center;
-o-transform-origin: center top center;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
text-align: center;
color: #ffffff;
}
We did two things. We updated .amg-corner-button_wrap:hover and .amg-corner-button_wrap:hover div to have a width and height of 100%. This way the panel would take up 100% of the panel.
The second change was adding:
.amg-corner-button:hover::before {
border-width: 0;
}
Without this we would be left with an extra triangle in panel. We need this triangle to create the green pocket shape we have in the bottom-right hand corner.
I first tried implementing it through two triangles. And got a satisfactory output
#wrapper {
margin-left: 40vw;
margin-top: 20vh;
}
#fidgetu {
width: 0;
height: 0;
position: absolute;
margin-top: 3vh;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-bottom: 100px solid red;
animation: rotate 2s linear infinite;
}
#fidgetd {
width: 0;
height: 0;
position: absolute;
margin-top: 3vh;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-top: 100px solid red;
animation: rotate 2s linear infinite;
}
#keyframes rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
<div id="wrapper">
<div id="fidgetu">
</div>
<div id="fidgetd">
</div>
</div>
I guess drawing a fidget spinner would require 4 div circles and 3 div rectangles to connect the central circle to the other three and a wrapper div (applying animate property to this div). But the positioning is messing up.
Now how do I position them appropriately such that the entire block rotates around its center?
Set an element as the base spinner, and then 3 childs of this one as the outer circles.
if the outer ones are positioned over the first one, just rotating the base elements will handle the rotation of the others.
A litlle tricky are the curves connecting the inner and the outer. I have set a solution, but there is some missalignment. It still needs a last adjustment on the pixel values (but it's hard to get it exactly)
.spinner, .outer {
width: 100px;
height: 100px;
border-radius: 50%;
position: absolute;
transform-style: preserve-3d;
}
.spinner {
background-color: teal;
border: solid 20px tomato;
margin: 100px;
animation: rotate 4s infinite linear;
}
.outer {
background-color: lightblue;
border: solid 20px blue;
left: -20px;
top: -20px;
}
.outer:before {
content: "";
position: absolute;
width: 150px;
height: 150px;
border-radius: 50%;
transform: translate(-91px, 104px);
box-shadow: 0px -55px 0px -33px blue;
}
.outer:after {
content: "";
position: absolute;
width: 150px;
height: 150px;
border-radius: 50%;
transform: translate(-83px, -156px);
box-shadow: 0px 55px 0px -33px blue;
}
.outer:nth-child(1) {
transform: translate3D(120px, 0px, -10px);
}
.outer:nth-child(2) {
transform: rotate(120deg) translate3D(120px, 0px, -10px);
}
.outer:nth-child(3) {
transform: rotate(240deg) translate3D(120px, 0px, -10px);
}
#keyframes rotate {
from {transform: rotate(0deg);}
to {transform: rotate(360deg);}
}
<div class="spinner">
<div class="outer"></div>
<div class="outer"></div>
<div class="outer"></div>
</div>
Is it possible to have a div with a background image which has a skewed bottom AND round corners?
Most examples use only a background color which doesn't have the duplicate image problem that a background image has.
CSS clipping path
The clipping path option works however, it has no support on IE 11.
Closest solution so far
The HTML:
<div class="container">
<div id="parallelogram">
<div class="image"></div>
</div>
</div>
The CSS:
.container {
overflow: hidden;
padding-bottom: 40px;
}
#parallelogram {
width: 300px;
height: 150px;
margin: -41px 0 0 0;
-webkit-transform: skewY(-11deg);
-moz-transform: skewY(-11deg);
-o-transform: skewY(-11deg);
background: red;
overflow: hidden;
position: relative;
border-radius: 40px;
}
.image {
background: url(http://baconmockup.com/340/500);
position: absolute;
top: -30px;
left: -30px;
right: -30px;
bottom: -30px;
-webkit-transform: skewY(11deg);
-moz-transform: skewY(11deg);
-o-transform: skewY(11deg);
}
https://jsfiddle.net/Spindle/81e30bmx/
But the problem with this is that the round corners aren't visible anymore as well...
Adding border-radius to parent div could work, as it will work as border-radius for four corner and then individually using border-top-right-radius, border-top-left-radius,border-bottom-right-radius,border-bottom-left-radius you can change and align accordingly as below and thus it skews at bottom-left along-with border-radius at 4 sides,
.container {
overflow: hidden;
padding-bottom: 40px;
border-top-right-radius:16px;
border-bottom-right-radius:14px;
border-top-left-radius:40px;
margin-top:40px;
display:inline-block;
}
#parallelogram {
width: 300px;
height: 150px;
margin: -41px 0 0 0;
-webkit-transform: skewY(-11deg);
-moz-transform: skewY(-11deg);
-o-transform: skewY(-11deg);
background: red;
overflow: hidden;
position: relative;
border-radius: 40px;
}
.image {
background: url(http://baconmockup.com/340/500);
position: absolute;
top: -30px;
left: -30px;
right: -30px;
bottom: -30px;
-webkit-transform: skewY(11deg);
-moz-transform: skewY(11deg);
-o-transform: skewY(11deg);
}
<div class="container">
<div id="parallelogram">
<div class="image"></div>
</div>
</div>
It is possible and does seems to work on your example.
If you are talking about the top left and right corners getting chopped off, then what you need to do is add a margin to the top so:
#parallelogram { margin: -41px 0 0 0; }
Would become:
#parallelogram { margin: 23px 0 0 0; }
This will adds the hole shape in.
This question already has answers here:
CSS3 Rotate Animation
(7 answers)
Closed 4 years ago.
I was wondering if it is possible to make a triangle that spins exactly from the center.
Codepen
html:
<div class="loader-wrapper">
<div class="loader"></div>
</div>
css:
.loader-wrapper {
width: 100%;
height: 100vh;
background-color: #11e;
}
#keyframes load {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.loader {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
width: 0;
height: 0;
border-style: solid;
border-width: 0 100px 173.2px 100px;
border-color: transparent transparent #007bff transparent;
animation: 4s linear 0s infinite load;
}
A complete solution could be like this.
Simply saying, you should change the transform origin that match the actual center of the triangle (which is 66.66% by pure math).
Html:
<div class="loader">
<div class="loader-wrapper">
<div class="triangle"></div>
</div>
</div>
CSS:
.loader {
display: inline-block;
position: relative;
width: 100%;
height: 300px;
}
.loader-wrapper {
display: block;
position: absolute;
top: 50%;
left: 50%;
/* transform by half of its width & height */
transform: translate(-50%, -50%);
}
.triangle {
display: block;
position: relative;
width: 0;
height: 0;
border-color: transparent transparent #e44750 transparent;
border-width: 0px 100px 173.20508076px 100px;
border-style: solid;
transform-origin: 50% 66.66%;
animation: spin 3s infinite linear;
}
#keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
The transform-origin property can be used to change the origin of the transformation point. just add transform-origin: 107px 111px; to your .loader class.
You'll need to do some tuning though, to get it perfect.
Try this:
.loader {
position: relative;
top: 50%;
transform: translate(0, -50%);
margin: auto;
width: 0;
height: 0;
border-style: solid;
border-width: 0 100px 173.2px 100px;
border-color: transparent transparent #007bff transparent;
animation: 4s linear 0s infinite load;
}
JSFiddle