I'm trying to create a ring like the one below:
There will be 5 or six on the page, each with a different level of the orange section going around the ring.
eg. 2 may have 50%, 1 has 30%, 1 has 80%, 1 40%
I can get the orange to be either 25%, 50%, 75%, 100% by following this:
<div class="wrapper">
<div class="arc arc_start"></div>
<div class="arc arc_end"></div>
</div>
.wrapper {
position:relative;
margin:20px;
}
.arc {
position:absolute;
top:0;
left:0;
width:100px;
height:100px;
border-radius:100%;
border:1px solid;
}
.arc_start {
border-color:transparent red red red;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
}
.arc_end {
border-color:red red red transparent;
-webkit-transform: rotate(75deg);
-moz-transform: rotate(75deg);
-ms-transform: rotate(75deg);
-o-transform: rotate(75deg);
transform: rotate(75deg);
}
from this jsfiddle
As its just adding colour to the border of the elements, but this doesn't really help me achieve my goal.
I could probably do this is canvas, but wanted to see if possible not using canvas.
Thanks in advance,
Tom
It seems to me that you almost have your answer.
You could use pseudo-element and rotate to hide/show portion of borders to draw in between 0,25,50,75 and 100% overlapping borders by borders.
http://codepen.io/gcyrillus/pen/JzmiE
div {
height:200px;
width:200px;
border:solid 5px black;
background:#159;
border-radius:100%;
display:inline-block;
margin:1em;
position:relative;
text-align:center;
line-height:200px;
color:white;
font-size:2em;
}
div:before,div:after {
content:'';
position:absolute;
top:-5px;
left:-5px;
border:solid 5px transparent;
height:inherit;
width:inherit;
border-radius:inherit;
}
.c30, .c40, .c50 {
border-left-color:tomato;
border-bottom-color:tomato;
}
.c30:before {
border-left-color:black;
transform:rotate(18deg)
}
.c40:before {
border-bottom-color:tomato;
transform:rotate(54deg)
}
.c80 {
border-color:tomato;
border-right-color:black;
}
.c80:before {
border-left-color:tomato;
transform:rotate(54deg)
}
body {background: #456;}
and html
<div class="c30">c30</div>
<div class="c40">c40</div>
<div class="c50">c50</div>
<div class="c80">c80</div>
<p>i.e. calculate rotation needed : 30%-25% = 5% of 360deg equals 18deg to increase rotation of one border to add those 5.%</p>
Related
I'm trying to set up a fixed div to the left of a page, 24px from the left and stretching from top to bottom of the page. Inside this div will be navigation and a title. I'm trying to get the title rotated -90 degrees and centered positioned toward the bottom of the div.
Having a tough time figuring this out. Looked around a lot of places and not seeing a similar example. I've set up a fiddle with the current code: https://jsfiddle.net/xkLc9xuy/2/
HTML:
<div>
<article></article>
<footer></footer>
<header></header>
<nav data-secondary></nav>
<nav data-primary>
<div>Website Title</div>
</nav>
</div>
SCSS:
#mixin -position($position:relative, $top:0, $right:0, $bottom:0, $left:0) {
position: $position;
#if $position !=relative {
top: $top;
right: $right;
bottom: $bottom;
left: $left;
}
}
#mixin -transform($transform) {
-ms-transform: $transform;
-webkit-transform: $transform;
transform: $transform;
}
#mixin -transform-origin($origin) {
-ms-transform-origin: $origin;
-webkit-transform-origin: $origin;
transform-origin: $origin;
}
body{
*:not(script){
margin:0;
padding:0;
#include -position;
}
> div{
#include -position(absolute);
}
}
nav[data-primary]{
box-shadow:0 0 8px rgba(0,0,0,0.5);
width:40px;
#include -position(absolute, 0, auto, 0, 24px);
> div{
white-space:nowrap;
height:40px;
line-height:40px;
background-color:red;
#include -transform(rotate(-90deg));
#include -transform-origin(left bottom);
}
}
You may also take a look at writing-mode:
-webkit-writing-mode: vertical-lr;
/* old Win safari */
writing-mode: vertical-rl;/*FF*/
writing-mode: tb-lr;
/* writing-mode:sideways-lr;
or eventually scale(-1,-1) untill sideways-lr is working everywhere */
transform: scale(-1, -1);
https://jsfiddle.net/xkLc9xuy/20/
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I've been toying around with animate.css and it has completely messed up my website. I'm not sure of the cause at all. Also I would like the animation to only happen when the div is in the view-port and I'm not sure how to do so.
https://road-aware.herokuapp.com/
You have to just override default animate.css behaviour. Because you already use transform in your css and animate.css overrides your css. ;)
See this jsfiddle sample
It's without browser prefixes, but that should be not big deal. ;)
#keyframes bounceInDown {
from, 60%, 75%, 90%, to {
-webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
}
0% {
opacity: 0;
transform: translate3d(-50%, -3000px, 0);
}
60% {
opacity: 1;
transform: translate3d(-50%, -40%, 0);
}
75% {
transform: translate3d(-50%, -60%, 0);
}
90% {
transform: translate3d(-50%, -45%, 0);
}
to {
transform: translate3d(-50%, -50%, 0);
}
}
Change your .landing-container to:
.landing-container {
text-align: center;
position: relative;
top: 50%;
padding: 15px 0;
box-sizing: border-box;
width: 80%;
-ms-transform: translate(-50%,-50%);
-webkit-transform: translate(-50%,-50%);
transform: translate(-50%,-50%);
margin: auto;
display: block;
}
Changing the position makes sure the element centers vertically. Removing left: 50% and adding margin: auto centers it horizontally. Adding the display: block makes the two above possible.
you can use overflow: hidden
<style type="text/css">
.examplediv {
background-color:#efefef;
border-style:solid #000000 1px;
}
#divid {
position:absolute;
left:450px; top:350px; width:35000px; height:35000px;
overflow:scroll;
}
</style>
<body>
<div id="divid" class="examplediv">
...
</div>
widthout
.examplediv
{
background-color:#efefef;
border-style:solid #000000 1px;
}
#divid
{
position:absolute;
left:450px; top:350px; width:35000px; height:35000px;
}
<body>
<div id="divid" class="examplediv">
</div>
http://www.css4you.de/overflow.html
I did a mobile navigation, what appears on the left when the user opens it. The navigation is fixed and it pushes the content to the right. I added overflow:hidden for body, and it removes the scrollbar on desktop but not on ios.
Style:
body{
padding:0;
margin:0;
overflow:hidden;
}
.opened-navigation#navigation {
-webkit-transform: translate(0, 0);
-moz-transform: translate(0, 0);
transform: translate(0, 0);
}
#navigation {
width:240px;
position:fixed;
left:0;
top:0;
height:100%;
background:yellow;
-webkit-transform: translate(-100%, 0);
-moz-transform: translate(-100%, 0);
transform: translate(-100%, 0);
}
.opened-navigation#content {
-webkit-transform: translate(240px, 0);
-moz-transform: translate(240px, 0);
transform: translate(240px, 0);
}
#content {
background:red;
}
HTML
<div id="navigation">Nav</div>
<div id="content">Content
<strong>Open Navigation</strong>
</div>
Javascript
$(document).ready(function(){
$('#opennav').click(function(e){
e.preventDefault();
$('#navigation, #content').toggleClass('opened-navigation');
});
});
When I add overflow:hidden for html it works, but on desktop it crops some of my elements. What is the solution?
Online version: http://psd-labs.com/demo/
I added position:relative; to body. I don't know why, but it fixed the problem.
I want to align the bars to the bottom here: http://jsfiddle.net/7vdLV/67/
I tried using the following trick:
.graph { position: relative; }
.weekbar { position: absolute; bottom: 0; left: 0; }
However it breaks the graph, can anyone tell me how I should do it please in this scenario?
Tweaked the HTML a bit as well as the CSS and got this: http://jsfiddle.net/7vdLV/74/
<div class="graph">
<div class="weekbar"><div style="height: 10%;"></div></div>
<div class="weekbar"><div style="height: 20%;"></div></div>
<div class="weekbar"><div style="height: 30%;"></div></div>
<div class="weekbar"><div style="height: 40%;"></div></div>
</div>
As TylerH pointed out inline styles are considered bad practice so you would be better replacing them with classes i.e.
<div class="graph">
<div class="weekbar"><div class="h10"></div></div>
<div class="weekbar"><div class="h20"></div></div>
<div class="weekbar"><div class="h30"></div></div>
<div class="weekbar"><div class="h40"></div></div>
</div>
.h10 {
height: 10%;
}
Try transform:
-moz-transform: scaleY(-1);
-o-transform: scaleY(-1);
-webkit-transform: scaleY(-1);
transform: scaleY(-1);
filter: FlipV;
-ms-filter: "FlipV";
http://jsfiddle.net/L4A2h/1/
Just replace the .graph class with the following code
.graph {
width: 100%;
height: 200px;
background-color: #eaeaea;
-moz-transform: scaleY(-1);
-o-transform: scaleY(-1);
-webkit-transform: scaleY(-1);
transform: scaleY(-1);
filter: FlipH;
-ms-filter: "FlipH";
}
Hope this Helps
Simplest solution:
apply
.weekbar{
position:relative;
display:inline-block;
top:50%; // height of biggest bar
}
Check this JSFiddle
Or if ancient browser support is not a big deal you can make use of the ::before element as follows:
.graph::before{
content:"";
display:block;
height:50%; // height of the biggest bar
}
.weekbar{
display:inline-block;
}
check this JSFiddle
Make these edits to your CSS:
.graph { position:relative; }
.weekbar { position: relative; top: 100%; left: 0; }
Is this what you were looking to do?
http://jsfiddle.net/4HEEk/
You can use position:relative; for the parent and position:relative; also for the child and calculate the top value by this jQuery code:
$(document).ready(function() {
var parentHeight = $('.graph').height();
$('.weekbar').each(function() {
var height = parentHeight - $(this).height();
$(this).css('top',height*100/parentHeight + '%');
});
});
Here is a working fiddle
I would change float for display:inline-block; then set an "invisible" resetter div at the start of your graph to make sure all the elements start from the bottom (rather from the bottom of the tallest line.
.weekbar {
width: 3.1%;
margin-left: -4px;
margin-right: 2%;
display:inline-block;
background-color: #aeaeae;
}
.resetter{
height:100%;
display:inline-block;
width:0;
margin-right:-4px;
}
Have a look at this JSFiddle.
Also on a note about inline style usage (dont do it!). If you know that you have a discrete number of heights (ie. in your example they are all multiples of 10) i would suggest creating classes for them.
Transition rotate causes chrome to flash black screen. Is it a Chrome bug (works fine in Safari) or it can be fixed with some clever css.
div {
width:200px;
height:200px;
position:relative;
background:#ddd;
}
span {
display:inline-block;
position:absolute;
top:40px;
left:40px;
width:20px;
background:#007;
height:10px;
-webkit-transition: all .5s;
}
div:hover > span {
-webkit-transform: rotate(180deg);
}
<div>
<span></span>
</div>
Example fiddle here.
The problem with this problem is that it doesn't occur every time so you'll have to hover the gray square several times and you should see the screen blinking in black.
Tested in:
Chrome 16.0.912.75
Chrome Canary 18.0.1010.0
Works fine on:
Safari 5.1.2 (6534.52.7)
All test on Snow Leopard
You can fix this by forcing compositing to stay on by giving -webkit-transform: translate3D(0, 0, 0) to the parent of the transformed element.
div { width:200px; height:200px; position:relative; background:#ddd; -webkit-transform: translate3D(0, 0, 0)}
span { display:inline-block; position:absolute; top:40px; left:40px; width:20px; background:#007; height:10px; -webkit-transition: -webkit-transform .5s; }
div:hover > span { -webkit-transform: rotate(180deg); }
<div>
<span></span>
</div>
Check out the fiddle: http://jsfiddle.net/UHLFF/