I'm trying to set two triangles in the following way:
The two triangles have to go from the middle to the outside of the browser. I tried to set it up with a wrapper and a background-color and then rotate the wrapper, but I cant get it responsive. The code I tried was:
#page-header-wrapper-triangle {
background-color:#e14b41 ;
-webkit-transform: rotate(-12deg) translate3d(0, 0, 0);
-moz-transform: rotate(-12deg);
-o-transform: rotate(-12deg);
-ms-transform: rotate(-12deg);
transform: rotate(-12deg);
margin: 0 -21px;
-webkit-transform-origin: left center;
-moz-transform-origin: left center;
-o-transform-origin: left center;
-ms-transform-origin: left center;
transform-origin: left center;
-webkit-backface-visibility: hidden;
outline: 1px solid transparent;
position: relative;
min-height: 204px;
z-index:1000;
width:80%;
}
#page-header-wrapper-triangle-2 {
background-color:#e14b41 ;
-webkit-transform: rotate(12deg) translate3d(0, 0, 0);
-moz-transform: rotate(12deg);
-o-transform: rotate(12deg);
-ms-transform: rotate(12deg);
transform: rotate(12deg);
margin: 0 -54px;
-webkit-transform-origin: left center;
-moz-transform-origin: left center;
-o-transform-origin: left center;
-ms-transform-origin: left center;
transform-origin: left center;
-webkit-backface-visibility: hidden;
outline: 1px solid transparent;
position: relative;
min-height: 204px;
z-index:1000;
width:80%;
float:right;
top:-520px;
}
<div id="page-header-wrapper-triangle">
<div class="container">
<div class="row">
<div class="right-red col-xs-12 col-sm-6">
</div>
<div class="left-blue col-xs-12 col-sm-6">
</div>
</div>
</div>
</div>
<div id="page-header-wrapper-triangle-2">
<div class="container">
<div class="row">
<div class="right-red col-xs-12 col-sm-6">
</div>
<div class="left-blue col-xs-12 col-sm-6">
</div>
</div>
</div>
</div>
This works when the width of the browser is 1920 px, but s soon as I change the width it doesn't work. I got no clue how I can get this responsive.
I also tried it with background pictures. But this also doesn't work.
You can do it with pseudo selectors :after. It's responsive-ready only for some small and mid widths. But you can easily customize with media queries and change the top and height value.
There is a live example using SCSS
.header {
background-color: grey;
padding-bottom: 60px;
padding-top: 60px;
position: relative;
display: inline-block;
width: 100%;
}
.header .block-left {
float: left;
width: 50%;
}
.header .block-left:after {
background-color: red;
content: ' ';
left: 0;
top: -125px;
height: 200px;
position: absolute;
transform: skew(0deg, -15deg);
width: 50%;
z-index: 20;
}
.header .block-right {
float: right;
width: 50%;
}
.header .block-right:after {
right: 0;
background-color: yellow;
content: ' ';
top: -125px;
height: 200px;
position: absolute;
transform: skew(0deg, 15deg);
width: 50%;
z-index: 20;
}
<div class="header">
<div class="block-left"></div>
<div class="block-right"></div>
</div>
Here's a explanation of how css triangles works : http://codepen.io/chriscoyier/pen/lotjh
#import url(http://fonts.googleapis.com/css?family=Andika);
$stepTiming: 0.8s 0.2s;
.triangle-demo {
width: 100px;
height: 100px;
margin: 0 auto;
background: tan;
border-top: 0 solid #EE7C31;
border-left: 0 solid #F5D97B;
border-bottom: 0 solid #D94948;
border-right: 0 solid #8DB434;
transition: $stepTiming;
.step-1 & {
border-top-width: 10px;
}
.step-2 & {
border-left-width: 10px;
}
.step-3 & {
border-right-width: 10px;
}
.step-4 & {
border-bottom-width: 10px;
}
.step-6 & {
background: transparent;
}
.step-7 & {
width: 0; height: 0;
}
.step-8 & {
border-left-color: transparent;
}
.step-9 & {
border-right-color: transparent;
}
.step-10 & {
border-top-color: transparent;
}
}
.triangle-title {
width: 300px;
padding: 1rem;
color: white;
background: #D94948;
border-radius: 20px;
margin: auto;
opacity: 0;
transition: $stepTiming;
.step-11 & {
opacity: 1;
}
}
body {
background: #333;
font-family: 'Andika', sans-serif;
color: white;
text-align: center;
font-size: large;
transform: translateZ(0);
}
.steps {
position: relative;
height: 45px;
> div {
position: absolute;
top: 0;
left: 0;
width: 100%;
opacity: 0;
background: #333;
transition: 0.3s;
}
.step-0 {
opacity: 1;
}
.step-1 & .step-1 {
opacity: 1;
}
.step-2 & .step-2 {
opacity: 1;
}
.step-5 & .step-5 {
opacity: 1;
}
.step-6 & .step-6 {
opacity: 1;
}
.step-7 & .step-7 {
opacity: 1;
}
.step-8 & .step-8 {
opacity: 1;
}
.step-11 & .step-11 {
opacity: 1;
}
}
h1 {
text-transform: uppercase;
letter-spacing: 1px;
font-size: 1.5rem;
border-bottom: 1px solid #555;
color: #999;
}
FYI http://1stwebdesigner.com/css-shapes/
Related
I have a pure css slider here but the problem is I dont want to scroll at the top of the slider when click the bullet and arrow navigation from the extra space.
Is there any way to achieve this with pure html or css?
I tried a href="#s3/" and a href="#s3!" but it's not working.
Looking for pure html and css solution since we have no script cms. Thanks
.wrapper {
overflow:scroll;
height:700px;
}
/* For visual purpose only */
.extra-space {
width: 100%;
height: 300px;
background: red;
line-height: 300px;
text-align: center;
}
/*slider*/
.CSSgal {
position: relative;
overflow: hidden;
/* Or set a fixed height */
}
/* SLIDER */
.CSSgal .slider {
height: 100%;
white-space: nowrap;
font-size: 0;
transition: 0.8s;
}
/* SLIDES */
.CSSgal .slider>* {
display: inline-block;
white-space: normal;
vertical-align: top;
height: 100%;
width: 100%;
background: none 50% no-repeat;
background-size: cover;
}
/* PREV/NEXT, CONTAINERS & ANCHORS */
.CSSgal .prevNext {
position: absolute;
z-index: 1;
top: 50%;
width: 100%;
height: 0;
}
.CSSgal .prevNext>div+div {
visibility: hidden;
/* Hide all but first P/N container */
}
.CSSgal .prevNext a {
text-align: center;
opacity: 0.7;
-webkit-transition: 0.3s;
transition: 0.3s;
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
border-radius: 0;
position: absolute;
width: 30px;
height: 30px;
display: inline-block;
padding: 3px;
}
.CSSgal .prevNext .right {
right: 30px;
left: auto;
position: absolute;
top: 50%;
width: 50px;
height: 50px;
border-radius: 50%;
background-color: hsla(0, 0%, 92.2%, .6) !important;
z-index: 1;
cursor: pointer;
background-image: none !important;
transition: all .3s;
}
.CSSgal .prevNext .left {
left: 30px;
position: absolute;
top: 50%;
width: 50px;
height: 50px;
border-radius: 50%;
background-image: none !important;
background-color: hsla(0, 0%, 92.2%, .6) !important;
z-index: 1;
cursor: pointer;
transition: all .3s;
}
.CSSgal .prevNext .left:before {
content: "";
position: absolute;
width: 20px;
height: 20px;
background: url(https://new.brandsforless.ae/static/media/m-sprite.7b312d28.png) no-repeat;
background-size: 300px;
display: inline-block;
background-position: -76.5px -7px;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
}
.CSSgal .prevNext .right:before {
content: "";
position: absolute;
width: 20px;
height: 20px;
background: url(https://new.brandsforless.ae/static/media/m-sprite.7b312d28.png) no-repeat;
background-size: 300px;
display: inline-block;
background-position: -49px -7.5px;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
}
.CSSgal .prevNext a:hover {
background-color: #ebebeb!important;
}
.CSSgal .prevNext a+a {
left: auto;
right: 0;
}
/* NAVIGATION */
.CSSgal .bullets {
position: absolute;
z-index: 2;
bottom: 0;
padding: 10px 0;
width: 100%;
text-align: center;
}
.CSSgal .bullets>a {
display: inline-block;
width: 12px;
height: 12px;
border-radius: 50%;
background: #f8d000;
border: 2px solid #f8d000;
-webkit-transition: 0.3s;
transition: 0.3s;
}
.CSSgal .bullets a span {
display: none;
}
.right {
transform: rotate(-45deg);
-webkit-transform: rotate(-45deg);
}
.left {
transform: rotate(135deg);
-webkit-transform: rotate(135deg);
}
.CSSgal .bullets>a+a {
background-color: rgba(255, 255, 255, 0.5);
border: 2px solid #999;
/* Dim all but first */
}
.CSSgal .bullets>a:hover {
background: #f8d000;
border: 2px solid #f8d000;
}
/* NAVIGATION BUTTONS */
/* ALL: */
.CSSgal>s:target~.bullets>* {
background-color: rgba(255, 255, 255, 0.5);
border: 2px solid #999;
}
/* ACTIVE */
#s1:target~.bullets>*:nth-child(1) {
background: #f8d000;
border: 2px solid #f8d000;
}
#s2:target~.bullets>*:nth-child(2) {
background: #f8d000;
border: 2px solid #f8d000;
}
#s3:target~.bullets>*:nth-child(3) {
background: #f8d000;
border: 2px solid #f8d000;
}
/* More slides? Add here more rules */
/* PREV/NEXT CONTAINERS VISIBILITY */
/* ALL: */
.CSSgal>s:target~.prevNext>* {
visibility: hidden;
}
/* ACTIVE: */
#s1:target~.prevNext>*:nth-child(1) {
visibility: visible;
}
#s2:target~.prevNext>*:nth-child(2) {
visibility: visible;
}
#s3:target~.prevNext>*:nth-child(3) {
visibility: visible;
}
/* More slides? Add here more rules */
/* SLIDER ANIMATION POSITIONS */
#s1:target~.slider {
transform: translateX(0%);
-webkit-transform: translateX(0%);
}
#s2:target~.slider {
transform: translateX(-100%);
-webkit-transform: translateX(-100%);
}
#s3:target~.slider {
transform: translateX(-200%);
-webkit-transform: translateX(-200%);
}
<div class="wrapper">
<section class="extra-space">
<h1>Extra space</h1>
</section>
<section class="mb-4">
<div class="container-fluid">
<div class="row">
<div class="col-12 p-0">
<div class="CSSgal">
<!-- Don't wrap targets in parent -->
<s id="s1"></s>
<s id="s2"></s>
<s id="s3"></s>
<div class="slider">
<div>
<a href="/en-ae/brands/troop-london/">
<img src="https://dummyimage.com/600x400/000/fff">
</a>
</div>
<div>
<img src="https://dummyimage.com/600x400/000/fff">
</div>
<div>
<img src="https://dummyimage.com/600x400/000/fff">
</div>
</div>
<div class="prevNext">
<div>
<a class="left" href="#s3"></a>
<a class="right" href="#s2"></a>
</div>
<div>
<a class="left" href="#s1"></a>
<a class="right" href="#s3"></a>
</div>
<div>
<a class="left" href="#s2"></a>
<a class="right" href="#s1"></a>
</div>
</div>
<div class="bullets">
<span>1</span>
<span>2</span>
<span>3</span>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
i manage to fix this by add s{display: none;} which hiding the id.
/*** the solution ***/
s{
display: none;
}
.wrapper {
overflow:scroll;
height:700px;
}
/* For visual purpose only */
.extra-space {
width: 100%;
height: 300px;
background: red;
line-height: 300px;
text-align: center;
}
/*slider*/
.CSSgal {
position: relative;
overflow: hidden;
/* Or set a fixed height */
}
/* SLIDER */
.CSSgal .slider {
height: 100%;
white-space: nowrap;
font-size: 0;
transition: 0.8s;
}
/* SLIDES */
.CSSgal .slider>* {
display: inline-block;
white-space: normal;
vertical-align: top;
height: 100%;
width: 100%;
background: none 50% no-repeat;
background-size: cover;
}
/* PREV/NEXT, CONTAINERS & ANCHORS */
.CSSgal .prevNext {
position: absolute;
z-index: 1;
top: 50%;
width: 100%;
height: 0;
}
.CSSgal .prevNext>div+div {
visibility: hidden;
/* Hide all but first P/N container */
}
.CSSgal .prevNext a {
text-align: center;
opacity: 0.7;
-webkit-transition: 0.3s;
transition: 0.3s;
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
border-radius: 0;
position: absolute;
width: 30px;
height: 30px;
display: inline-block;
padding: 3px;
}
.CSSgal .prevNext .right {
right: 30px;
left: auto;
position: absolute;
top: 50%;
width: 50px;
height: 50px;
border-radius: 50%;
background-color: hsla(0, 0%, 92.2%, .6) !important;
z-index: 1;
cursor: pointer;
background-image: none !important;
transition: all .3s;
}
.CSSgal .prevNext .left {
left: 30px;
position: absolute;
top: 50%;
width: 50px;
height: 50px;
border-radius: 50%;
background-image: none !important;
background-color: hsla(0, 0%, 92.2%, .6) !important;
z-index: 1;
cursor: pointer;
transition: all .3s;
}
.CSSgal .prevNext .left:before {
content: "";
position: absolute;
width: 20px;
height: 20px;
background: url(https://new.brandsforless.ae/static/media/m-sprite.7b312d28.png) no-repeat;
background-size: 300px;
display: inline-block;
background-position: -76.5px -7px;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
}
.CSSgal .prevNext .right:before {
content: "";
position: absolute;
width: 20px;
height: 20px;
background: url(https://new.brandsforless.ae/static/media/m-sprite.7b312d28.png) no-repeat;
background-size: 300px;
display: inline-block;
background-position: -49px -7.5px;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
}
.CSSgal .prevNext a:hover {
background-color: #ebebeb!important;
}
.CSSgal .prevNext a+a {
left: auto;
right: 0;
}
/* NAVIGATION */
.CSSgal .bullets {
position: absolute;
z-index: 2;
bottom: 0;
padding: 10px 0;
width: 100%;
text-align: center;
}
.CSSgal .bullets>a {
display: inline-block;
width: 12px;
height: 12px;
border-radius: 50%;
background: #f8d000;
border: 2px solid #f8d000;
-webkit-transition: 0.3s;
transition: 0.3s;
}
.CSSgal .bullets a span {
display: none;
}
.right {
transform: rotate(-45deg);
-webkit-transform: rotate(-45deg);
}
.left {
transform: rotate(135deg);
-webkit-transform: rotate(135deg);
}
.CSSgal .bullets>a+a {
background-color: rgba(255, 255, 255, 0.5);
border: 2px solid #999;
/* Dim all but first */
}
.CSSgal .bullets>a:hover {
background: #f8d000;
border: 2px solid #f8d000;
}
/* NAVIGATION BUTTONS */
/* ALL: */
.CSSgal>s:target~.bullets>* {
background-color: rgba(255, 255, 255, 0.5);
border: 2px solid #999;
}
/* ACTIVE */
#s1:target~.bullets>*:nth-child(1) {
background: #f8d000;
border: 2px solid #f8d000;
}
#s2:target~.bullets>*:nth-child(2) {
background: #f8d000;
border: 2px solid #f8d000;
}
#s3:target~.bullets>*:nth-child(3) {
background: #f8d000;
border: 2px solid #f8d000;
}
/* More slides? Add here more rules */
/* PREV/NEXT CONTAINERS VISIBILITY */
/* ALL: */
.CSSgal>s:target~.prevNext>* {
visibility: hidden;
}
/* ACTIVE: */
#s1:target~.prevNext>*:nth-child(1) {
visibility: visible;
}
#s2:target~.prevNext>*:nth-child(2) {
visibility: visible;
}
#s3:target~.prevNext>*:nth-child(3) {
visibility: visible;
}
/* More slides? Add here more rules */
/* SLIDER ANIMATION POSITIONS */
#s1:target~.slider {
transform: translateX(0%);
-webkit-transform: translateX(0%);
}
#s2:target~.slider {
transform: translateX(-100%);
-webkit-transform: translateX(-100%);
}
#s3:target~.slider {
transform: translateX(-200%);
-webkit-transform: translateX(-200%);
}
<div class="wrapper">
<section class="extra-space">
<h1>Extra space</h1>
</section>
<section class="mb-4">
<div class="container-fluid">
<div class="row">
<div class="col-12 p-0">
<div class="CSSgal">
<!-- Don't wrap targets in parent -->
<s id="s1"></s>
<s id="s2"></s>
<s id="s3"></s>
<div class="slider">
<div>
<a href="/en-ae/brands/troop-london/">
<img src="https://dummyimage.com/600x400/000/fff">
</a>
</div>
<div>
<img src="https://dummyimage.com/600x400/000/fff">
</div>
<div>
<img src="https://dummyimage.com/600x400/000/fff">
</div>
</div>
<div class="prevNext">
<div>
<a class="left" href="#s3"></a>
<a class="right" href="#s2"></a>
</div>
<div>
<a class="left" href="#s1"></a>
<a class="right" href="#s3"></a>
</div>
<div>
<a class="left" href="#s2"></a>
<a class="right" href="#s1"></a>
</div>
</div>
<div class="bullets">
<span>1</span>
<span>2</span>
<span>3</span>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
I created a speedometer that works very well and is to light (with CSS3,html and js code).
But i noticed a strange bug with iphone....
This is the CODE:
$('#first').addClass('first-start');
//SECOND BAR
$('#second').addClass('second-start');
setTimeout(function() {
$('#second').addClass('second-pause');
}, 400);
#page {
margin-top: 50px;
width: 300px;
height: 300px;
background-color: #000;
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
z-index: 4;
overflow: hidden;
}
#box-first,
#box-second {
width: 200px;
height: 100px;
background-color: #fff;
border-radius: 200px 200px 0 0;
margin-top: 10px;
margin-bottom: 10px;
position: relative;
display: flex;
justify-content: flex-end;
align-items: flex-start;
z-index: 3;
overflow: hidden;
}
#first,
#second {
border-radius: 200px 200px 0 0;
margin: 0;
background: red;
width: 200px;
height: 100px;
transform: rotate(180deg);
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
-ms-transform: rotate(180deg);
-o-transform: rotate(180deg);
transform-origin: 50% 100%;
-webkit-transform-origin: 50% 100%;
-moz-transform-origin: 50% 100%;
-ms-transform-origin: 50% 100%;
position: absolute;
top: 0px;
right: 0px;
border: 0;
z-index: 1;
}
#n1,
#n2 {
font-size: 20px;
color: #fff;
font-weight: bold;
position: absolute;
left: 50px;
right: 0;
text-align: center;
top: 50px;
bottom: 0;
display: flex;
align-items: flex-end;
justify-content: center;
width: 100px;
height: 50px;
background: #000;
border-radius: 100px 100px 0 0;
z-Index: 1;
overflow: hidden;
}
#keyframes first {
0% {
background-color: green;
transform: rotate(180deg);
}
33% {
background-color: yellow;
transform: rotate(240deg);
}
66% {
background-color: orange;
transform: rotate(300deg);
}
100% {
background-color: red;
transform: rotate(360deg);
}
}
#keyframes second {
0% {
background-color: green;
transform: rotate(180deg);
}
33% {
background-color: yellow;
transform: rotate(240deg);
}
66% {
background-color: orange;
transform: rotate(300deg);
}
100% {
background-color: red;
transform: rotate(360deg);
}
}
.first-start,
.second-start {
animation: first 2s linear forwards;
}
.first-pause,
.second-pause {
animation-play-state: paused;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="page">
<div id="box-first">
<div id="first"></div>
<div id="n1">1500</div>
</div>
<div id="box-second">
<div id="second"></div>
<div id="n2">270</div>
</div>
</div>
With iphone, so with safari, under (at the bottom side) div #n1 (the black div where there's number 1500) is visible a small white border or sometimes red (like #first).
And this is impossible because the container has overflow: hidden, all divs have different z-Index and the absolute position of #n1 is correct.
How is possibile ?
Thanks and sorry for my english
This is the jsfiddle: This is jsfiddle: https://jsfiddle.net/k85t9zgq/33/
This is a bug's screenshot:
THIS IS NEW "BUG" adding box-sizing:border-box
it seems to me that adding this new property not work the overflow:hidden property.
Is possible?
I cannot test this, but I am pretty sure it's related to the fact that background use background-clip border-box by default and this is somehow a rendring issue. A potential fix is to make the background far from the border by adding a small padding and adjusting background-clip
$('#first').addClass('first-start');
//SECOND BAR
$('#second').addClass('second-start');
setTimeout(function() {
$('#second').addClass('second-pause');
}, 400);
#page {
margin-top: 50px;
width: 300px;
height: 300px;
background-color: #000;
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
z-index: 4;
overflow: hidden;
}
#box-first,
#box-second {
width: 200px;
height: 100px;
/* Changes*/
background: linear-gradient(#fff,#fff) content-box;
padding:1px;
box-sizing:border-box;
/**/
border-radius: 200px 200px 0 0;
margin-top: 10px;
margin-bottom: 10px;
position: relative;
display: flex;
justify-content: flex-end;
align-items: flex-start;
z-index: 3;
overflow: hidden;
}
#first,
#second {
border-radius: 200px 200px 0 0;
margin: 0;
background: red;
width: 200px;
height: 100px;
transform: rotate(180deg);
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
-ms-transform: rotate(180deg);
-o-transform: rotate(180deg);
transform-origin: 50% 100%;
-webkit-transform-origin: 50% 100%;
-moz-transform-origin: 50% 100%;
-ms-transform-origin: 50% 100%;
position: absolute;
top: 0px;
right: 0px;
border: 0;
z-index: 1;
}
#n1,
#n2 {
font-size: 20px;
color: #fff;
font-weight: bold;
position: absolute;
left: 50px;
right: 0;
text-align: center;
top: 50px;
bottom: 0;
display: flex;
align-items: flex-end;
justify-content: center;
width: 100px;
height: 50px;
background: #000;
border-radius: 100px 100px 0 0;
z-Index: 1;
overflow: hidden;
}
#keyframes first {
0% {
background-color: green;
transform: rotate(180deg);
}
33% {
background-color: yellow;
transform: rotate(240deg);
}
66% {
background-color: orange;
transform: rotate(300deg);
}
100% {
background-color: red;
transform: rotate(360deg);
}
}
#keyframes second {
0% {
background-color: green;
transform: rotate(180deg);
}
33% {
background-color: yellow;
transform: rotate(240deg);
}
66% {
background-color: orange;
transform: rotate(300deg);
}
100% {
background-color: red;
transform: rotate(360deg);
}
}
.first-start,
.second-start {
animation: first 2s linear forwards;
}
.first-pause,
.second-pause {
animation-play-state: paused;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="page">
<div id="box-first">
<div id="first"></div>
<div id="n1">1500</div>
</div>
<div id="box-second">
<div id="second"></div>
<div id="n2">270</div>
</div>
</div>
I believe it's your border-radius property on #first and #second - Play around with the values on it and you will totally see what I mean.
Change this:
#first,
#second {
border-radius: 200px 200px 0 0; /* ← CHANGE THIS */
margin: 0;
background: red;
width: 200px; /* ← CHANGE THIS TOO */
height: 100px;
transform: rotate(180deg);
transform-origin: 50% 100%;
position: absolute;
top: 0px;
right: 0px;
border: 0;
z-index: 1;
}
to:
#first,
#second {
border-radius: 0; /* ← THIS IS WHAT YOU WANT */
margin: 0;
background: red;
width: 100%; /* ← THIS IS ALSO WHAT YOU WANT */
height: 100px;
transform: rotate(180deg);
transform-origin: 50% 100%;
position: absolute;
top: 0px;
right: 0px;
border: 0;
z-index: 1;
}
That faint white/gray line around your speedometer is no longer present.
Cheers and Happy coding :)
I need to get the text of div with id='form1' and id='form2' to fit inside their respective container. Currently, the number 40 should be inside the white box on the left but for some reason, it got pushed down.I have tried inserting span and div tag inside form1/form2 but it doesn't do anything. I also try word-wrap in CSS and nothing change.
.form1{
width: 20%;
height: 8%;
float: left;
background: white;
margin-top: 55%;
border-radius: 0px 20px 20px 0px;
opacity: .5;
position: absolute;
}
.form2{
width: 20%;
height: 8%;
float: right;
margin-top: 55%;
background: white;
border-radius: 20px 0px 0px 20px;
opacity: .5;
}
.box1{
width: 60%;
height: 50%;
background: url(http://i.imgur.com/lpaxZUu.png) center no-repeat ;
vertical-align:center;
position: absolute;
margin: 30% 20%;
}
#container
{
width: 10em;
height: 12em;
font-size: 2em;
text-align: center;
line-height: 5em;
margin: 3em auto;
border: 2px solid #666;
border-radius: 7px;
position: relative;
overflow: hidden;
}
#container:before
{
content: "";
position: absolute;
width: 200%;
height: 200%;
top: -50%;
left: -50%;
z-index: -1;
background: url(http://i.imgur.com/opsUkHF.png) center ;
-webkit-transition: all 1s;
-moz-transition: all 1s;
-ms-transition: all 1s
-o-transition: all 1s;
transition: all 1s;
}
.transform:before {
-webkit-transform: rotate(-30deg);
-moz-transform: rotate(-30deg);
-ms-transform: rotate(-30deg);
-o-transform: rotate(-30deg);
transform: rotate(-30deg);
}
.text1{
width: 100%;
height: 100%;
background: black;
position: absolute;
font-size: 20px;
display: inline-block;
}
<div id="container">
<div class='form1'>40</div>
<div class="box1"></div>
<div class='form2'></div>
</div>
Here is the jsfiddle to illustrate the code : https://jsfiddle.net/xffc49qL/8/
Your form1 containers line-height is the reason why your text is out of the box. change it to line-height: normal, it should bring back the content within the form1. Also, absolute doesn't have any impact in your case, as the element is float already.
All you need to change is form1 elements line-height.
.form1 {
width: 20%;
height: 8%;
float: left;
background: white;
margin-top: 55%;
border-radius: 0px 20px 20px 0px;
opacity: .5;
line-height: normal;
}
.form2 {
width: 20%;
height: 8%;
float: right;
margin-top: 55%;
background: white;
border-radius: 20px 0px 0px 20px;
opacity: .5;
}
.box1 {
width: 60%;
height: 50%;
background: url(http://i.imgur.com/lpaxZUu.png) center no-repeat;
vertical-align: center;
position: absolute;
margin: 30% 20%;
}
#container {
width: 10em;
height: 12em;
font-size: 2em;
text-align: center;
line-height: 5em;
margin: 3em auto;
border: 2px solid #666;
border-radius: 7px;
position: relative;
overflow: hidden;
}
#container:before {
content: "";
position: absolute;
width: 200%;
height: 200%;
top: -50%;
left: -50%;
z-index: -1;
background: url(http://i.imgur.com/opsUkHF.png) center;
-webkit-transition: all 1s;
-moz-transition: all 1s;
-ms-transition: all 1s -o-transition: all 1s;
transition: all 1s;
}
.transform:before {
-webkit-transform: rotate(-30deg);
-moz-transform: rotate(-30deg);
-ms-transform: rotate(-30deg);
-o-transform: rotate(-30deg);
transform: rotate(-30deg);
}
.text1 {
width: 100%;
height: 100%;
background: black;
position: absolute;
font-size: 20px;
display: inline-block;
}
<div id="container">
<div class='form1'>40</div>
<div class="box1"></div>
<div class='form2'></div>
</div>
use position:absolute to fix your variable on a particular position
#test{
position:absolute;
margin-top:-62px;
margin-left:-10px;
}
.form1{
width: 20%;
height: 8%;
float: left;
background: white;
margin-top: 55%;
border-radius: 0px 20px 20px 0px;
opacity: .5;
position: absolute;
}
.form2{
width: 20%;
height: 8%;
float: right;
margin-top: 55%;
background: white;
border-radius: 20px 0px 0px 20px;
opacity: .5;
}
.box1{
width: 60%;
height: 50%;
background: url(http://i.imgur.com/lpaxZUu.png) center no-repeat ;
vertical-align:center;
position: absolute;
margin: 30% 20%;
}
#container
{
width: 10em;
height: 12em;
font-size: 2em;
text-align: center;
line-height: 5em;
margin: 3em auto;
border: 2px solid #666;
border-radius: 7px;
position: relative;
overflow: hidden;
}
#container:before
{
content: "";
position: absolute;
width: 200%;
height: 200%;
top: -50%;
left: -50%;
z-index: -1;
background: url(http://i.imgur.com/opsUkHF.png) center ;
-webkit-transition: all 1s;
-moz-transition: all 1s;
-ms-transition: all 1s
-o-transition: all 1s;
transition: all 1s;
}
.transform:before {
-webkit-transform: rotate(-30deg);
-moz-transform: rotate(-30deg);
-ms-transform: rotate(-30deg);
-o-transform: rotate(-30deg);
transform: rotate(-30deg);
}
.text1{
width: 100%;
height: 100%;
background: black;
position: absolute;
font-size: 20px;
display: inline-block;
}
<div id="container">
<div class='form1'><div id='text1'><span id="test">40</span></div></div>
<div class="box1"></div>
<div class='form2'></div>
</div>
Add margin-top: -64px; in #test to get it positioned inside the box
.form1{
width: 20%;
height: 8%;
float: left;
background: white;
margin-top: 55%;
border-radius: 0px 20px 20px 0px;
opacity: .5;
position: absolute;
}
.form2{
width: 20%;
height: 8%;
float: right;
margin-top: 55%;
background: white;
border-radius: 20px 0px 0px 20px;
opacity: .5;
}
.box1{
width: 60%;
height: 50%;
background: url(http://i.imgur.com/lpaxZUu.png) center no-repeat ;
vertical-align:center;
position: absolute;
margin: 30% 20%;
}
#container
{
width: 10em;
height: 12em;
font-size: 2em;
text-align: center;
line-height: 5em;
margin: 3em auto;
border: 2px solid #666;
border-radius: 7px;
position: relative;
overflow: hidden;
}
#container:before
{
content: "";
position: absolute;
width: 200%;
height: 200%;
top: -50%;
left: -50%;
z-index: -1;
background: url(http://i.imgur.com/opsUkHF.png) center ;
-webkit-transition: all 1s;
-moz-transition: all 1s;
-ms-transition: all 1s
-o-transition: all 1s;
transition: all 1s;
}
.transform:before {
-webkit-transform: rotate(-30deg);
-moz-transform: rotate(-30deg);
-ms-transform: rotate(-30deg);
-o-transform: rotate(-30deg);
transform: rotate(-30deg);
}
.text1{
width: 100%;
height: 100%;
background: black;
position: absolute;
font-size: 20px;
display: inline-block;
}
#test
{
margin-top: -64px;
}
<div id="container">
<div class='form1'><div id='text1'>40</div></div>
<div class="box1"></div>
<div class='form2'></div>
</div>
Can you explain why you are using line-height? If you remove line-height, the code works. Try it in fiddle. Comment out line-height in #container style. The text '0' will move inside the form1 and form2.
I am trying to simulate n amount of boxes rotating from the bottom-right position of the preposition div.
So, basically, I want the top left absolute position of n, be the same as the bottom right absolute position of n - 1. I really hope I explained this well enough, I just don't want there to be a gap, and want the boxes to rotate from the top left without moving to the right or to the bottom.
I tried adding transform-origin: 0 0; but it still won't work.
I appreciate any help, thank you in advance.
Here is the CSS:
.con {
margin: 50px;
width: 100px;
clear: both;
position: relative;
}
.box:nth-child(5) {
width: 150px;
height: 150px;
outline: 1px solid black;
margin-left: -15px;
margin-top: -15px;
position: absolute;
transform-origin: 0 0;
transform: translate(140px, 140px) rotate(10deg);
}
.box:nth-child(4) {
width: 120px;
height: 120px;
outline: 1px solid black;
margin-left: 138px;
margin-top: 138px;
position: absolute;
transform-origin: 0 0;
transform: translate(110px, 110px) rotate(10deg);
}
.box:nth-child(3) {
width: 90px;
height: 90px;
outline: 1px solid black;
margin-left: 261px;
margin-top: 261px;
position: absolute;
transform-origin: 0 0;
transform: translate(80px, 80px) rotate(10deg);
}
.box:nth-child(2) {
width: 60px;
height: 60px;
outline: 1px solid black;
margin-left: 354px;
margin-top: 354px;
position: absolute;
transform-origin: 0 0;
transform: translate(50px, 50px) rotate(10deg);
}
.box:nth-child(1) {
width: 30px;
height: 30px;
outline: 1px solid black;
margin-left: 417px;
margin-top: 417px;
position: absolute;
transform-origin: 0 0;
transform: translate(20px, 20px) rotate(10deg);
}
And the HTML
<div class='con'>
<div class='box'></div>
<div class='box'></div>
<div class='box'></div>
<div class='box'></div>
<div class='box'></div>
<div class='box'></div>
<div class='box'></div>
<div class='box'></div>
<div class='box'></div>
<div class='box'></div>
</div>
This is what it looks like now:
And here is the the codepen where you can see the sandbox live.
I assume this is what you are after.
View the link for the code to make sence.
http://codepen.io/anon/pen/bppRBx?editors=1111
.con {
margin: 50px;
width: 100px;
clear: both;
position: relative;
}
.box:nth-child(5) {
width: 150px;
height: 150px;
outline: 1px solid black;
margin-left: 0px;
margin-top: 0px;
position: absolute;
transform-origin: 0 0;
transform: rotate(0deg);
}
.box:nth-child(4) {
width: 120px;
height: 120px;
outline: 1px solid black;
margin-left: 149.99962px;
margin-top: 149.99962px;
position: absolute;
transform-origin: 0 0;
transform: rotate(-10deg);
}
.box:nth-child(3) {
width: 90px;
height: 90px;
outline: 1px solid black;
margin-left: 289.01398px;
margin-top: 247.33853px;
position: absolute;
transform-origin: 0 0;
transform: rotate(-20deg);
}
.box:nth-child(2) {
width: 60px;
height: 60px;
outline: 1px solid black;
margin-left: 404.36784px;
margin-top: 301.12891px;
position: absolute;
transform-origin: 0 0;
transform: rotate(-30deg);
}
.box:nth-child(1) {
width: 30px;
height: 30px;
outline: 1px solid black;
margin-left: 486.32916px;
margin-top: 323.09038px;
position: absolute;
transform-origin: 0 0;
transform: rotate(-40deg);
}
To calculate the start point of each new rectangle you need to use some trigonmetry to calculate the end position of the last one. Since this is not included in SASS/CSS you have to write your own functions.
Daniel Perez Alvarez did a nice blog post on how to create simmplified versions of COS/SIN functions in SASS:
https://unindented.org/articles/trigonometry-in-sass/
use css attribute 'transform':
.your-class:hover {
transform: rotate(-45deg);
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transition: transform 0.8s ease;
-webkit-transition: -webkit-transform 0.8s ease;
-moz-transition: -moz-transform 0.8s ease;
-o-transition: -o-transform 0.8s ease;
}
I would be interested to know if you can make a modal pop-up window just using HTML and CSS without JQuery.
Does anyone know such a simple example?
Thanks in advance!
A modal with only HTML and CSS no jQuery or javascript
body {
color: #333333;
font-family: 'Helvetica', arial;
height: 80em;
}
.wrap {
padding: 40px;
text-align: center;
}
hr {
clear: both;
margin-top: 40px;
margin-bottom: 40px;
border: 0;
border-top: 1px solid #aaaaaa;
}
h1 {
font-size: 30px;
margin-bottom: 40px;
}
p {
margin-bottom: 20px;
}
.btn {
background: #428bca;
border: #357ebd solid 1px;
border-radius: 3px;
color: #fff;
display: inline-block;
font-size: 14px;
padding: 8px 15px;
text-decoration: none;
text-align: center;
min-width: 60px;
position: relative;
transition: color .1s ease;
/* top: 40em;*/
}
.btn:hover {
background: #357ebd;
}
.btn.btn-big {
font-size: 18px;
padding: 15px 20px;
min-width: 100px;
}
.btn-close {
color: #aaaaaa;
font-size: 30px;
text-decoration: none;
position: absolute;
right: 5px;
top: 0;
}
.btn-close:hover {
color: #919191;
}
.modal:before {
content: "";
display: none;
background: rgba(0, 0, 0, 0.6);
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 10;
}
.modal:target:before {
display: block;
}
.modal:target .modal-dialog {
-webkit-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0);
top: 20%;
}
.modal-dialog {
background: #fefefe;
border: #333333 solid 1px;
border-radius: 5px;
margin-left: -200px;
position: fixed;
left: 50%;
top: -100%;
z-index: 11;
width: 360px;
-webkit-transform: translate(0, -500%);
-ms-transform: translate(0, -500%);
transform: translate(0, -500%);
-webkit-transition: -webkit-transform 0.3s ease-out;
-moz-transition: -moz-transform 0.3s ease-out;
-o-transition: -o-transform 0.3s ease-out;
transition: transform 0.3s ease-out;
}
.modal-body {
padding: 20px;
}
.modal-header,
.modal-footer {
padding: 10px 20px;
}
.modal-header {
border-bottom: #eeeeee solid 1px;
}
.modal-header h2 {
font-size: 20px;
}
.modal-footer {
border-top: #eeeeee solid 1px;
text-align: right;
}
/*ADDED TO STOP SCROLLING TO TOP*/
#close {
display: none;
}
<div class="wrap">
<h1>Modal - Pure CSS (no Javascript)</h1>
<hr />
Modal!
</div>
<!-- Modal -->
<div class="modal" id="modal-one" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-header">
<h2>Modal in CSS?</h2>
× <!--CHANGED TO "#close"-->
</div>
<div class="modal-body">
<p>One modal example here! :D</p>
</div>
<div class="modal-footer">
Nice! <!--CHANGED TO "#close"-->
</div>
</div>
</div>
</div>
<!-- /Modal -->
Yes, it is possible.
You can use the :target pseudo selector to show a modal.
Here's an example including some transitions as well (code combined from shehary's codepen example and http://tympanus.net/Development/ModalWindowEffects):
body {
background-color: #e74c3c;
}
a {
background-color: #c0392b;
color: #fff;
text-align: center;
width: 200px;
height: 50px;
line-height: 50px;
text-decoration: none;
border-radius: 2px;
}
a:hover {
background-color: #a5281b;
}
body > a {
display: block;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.md-modal {
position: fixed;
top: 50%;
left: 50%;
width: 50%;
max-width: 630px;
min-width: 320px;
height: auto;
z-index: 2000;
visibility: hidden;
transform: translateX(-50%) translateY(-50%);
}
.md-modal:target {
visibility: visible;
}
.md-overlay {
position: fixed;
width: 100%;
height: 100%;
visibility: hidden;
top: 0;
left: 0;
z-index: 1000;
opacity: 0;
background: rgba(143,27,15,0.8);
transition: all 0.3s;
}
.md-modal:target ~ .md-overlay {
opacity: 1;
visibility: visible;
}
/* Content styles */
.md-content {
color: #fff;
background: #e74c3c;
position: relative;
border-radius: 3px;
margin: 0 auto;
}
.md-content h3 {
margin: 0;
padding: 0.4em;
text-align: center;
font-size: 2.4em;
font-weight: 300;
opacity: 0.8;
background: rgba(0,0,0,0.1);
border-radius: 3px 3px 0 0;
}
.md-content > div {
padding: 15px 40px 30px;
margin: 0;
font-weight: 300;
font-size: 1.15em;
}
.md-content > div p {
margin: 0;
padding: 10px 0;
}
.md-content > div ul {
margin: 0;
padding: 0 0 30px 20px;
}
.md-content > div ul li {
padding: 5px 0;
}
.md-content a {
display: block;
margin: 0 auto;
font-size: 0.8em;
}
/* Effect */
.md-modal .md-content {
-webkit-transform: scale(0.7);
-moz-transform: scale(0.7);
-ms-transform: scale(0.7);
transform: scale(0.7);
opacity: 0;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
transition: all 0.3s;
}
.md-modal:target .md-content {
-webkit-transform: scale(1);
-moz-transform: scale(1);
-ms-transform: scale(1);
transform: scale(1);
opacity: 1;
}
MODAL
<div class="md-modal" id="modal">
<div class="md-content">
<h3>Modal Dialog</h3>
<div>
<p>This is a modal window.</p>
<a class="md-close" href="#">Close me!</a>
</div>
</div>
</div>
<div class="md-overlay"></div>
If you don't feel comfortable using visibility: hidden you can use display: none instead. But you better remove the transitions in that case (visibility can be used in a transition, display can't).