I have a requirement like below.
I am able to go through https://css-tricks.com/snippets/css/css-triangle/ website and generate triangle. I want to know how to attach it to a border and get the desired dimension of height 10px and width of 40px.
You need to make the position: relative; of the parent div and position: absolute; of the child div in which you want to make the arrow.
Main thing by which the arrows are made is transform property.
It is working properly. But here the size of the arrow is just 2x that you want.
* {box-sizing: border-box;}
.line {height: 20px; border-bottom: solid 2px #000; margin-top: 100px; position: relative; z-index: 1;}
.arrow {content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); height: 20px; width: 80px; z-index: 2; background-color: #fff;}
.arrow .pin {width: calc(50% + 5px); height: 2px; background: #000; display: inline-block; float: left; transform: rotate(25deg); transform-origin: 0 0;}
.arrow .pin:last-child {transform: rotate(-25deg); transform-origin: 100% 0; float: right; margin-top: -2px;}
<div class="line">
<div class="arrow">
<div class="pin">
</div>
<div class="pin">
</div>
</div>
</div>
And it is with 40px x 10px size of arrow.
* {box-sizing: border-box;}
.line {height: 20px; border-bottom: solid 2px #000; margin-top: 100px; position: relative; z-index: 1;}
.arrow {content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); height: 10px; width: 40px; z-index: 2; background-color: #fff;}
.arrow .pin {width: calc(50% + 3px); height: 2px; background: #000; display: inline-block; float: left; transform: rotate(25deg); transform-origin: 0 0;}
.arrow .pin:last-child {transform: rotate(-25deg); transform-origin: 100% 0; float: right; margin-top: -2px;}
<div class="line">
<div class="arrow">
<div class="pin">
</div>
<div class="pin">
</div>
</div>
</div>
That's pretty straightforward.
Step 1: You give the position: relative; property for the div to which you want to add the arrow.
Step 2: add the CSS arrow: <div class="arrow-down"></div> And apply a position: absolute; property to it so that you could position it as required.
So, if you had a div with the class box, this is what you would do:
.box {
width: 200px;
height: 150px;
background-color:red;
margin: 30px auto;
position: relative;
}
.arrow-down {
width: 0;
height: 0;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-top: 10px solid #f00;
position: absolute;
bottom: -10px;
left: 80px;
}
<div class="box">
<div class="arrow-down"></div>
</div>
Here's a fiddle for the same: https://jsfiddle.net/t2ne282z/
Hi for a webshop i want the product block to open like a book. and show a image on de inside-left (when opened)
i tried to do this. It works ok but i want the black div to open to the left. this one will contain the image. When i put a negivate -180 degrees it does not seem to work ok.
.left,
.right {
width: 100%;
height: 200px;
float: left;
color: white;
position: absolute;
}
.left {
background: red;
-webkit-border-top-left-radius: 100px;
-webkit-border-bottom-right-radius: 100px;
-moz-border-radius-topleft: 100px;
-moz-border-radius-bottomright: 100px;
border-top-left-radius: 100px;
border-bottom-right-radius: 100px;
height: 250px;
padding: 0;
border: 10px solid #10832d;
}
.right {
background: black;
-webkit-border-top-left-radius: 100px;
-webkit-border-bottom-right-radius: 100px;
-moz-border-radius-topleft: 100px;
-moz-border-radius-bottomright: 100px;
border-top-left-radius: 100px;
border-bottom-right-radius: 100px;
height: 250px;
padding: 0;
border: 10px solid #10832d;
}
.wrapper {
perspective: 1000px;
perspective-origin: 100%;
100%;
;
-webkit-perspective: 1000px;
-webkit-perspective-origin: 100%;
100%;
;
}
.wrapper:hover .right {
transform: rotate3d(0, 1, 0, -180deg);
transform: rotateY(180deg);
transform-origin: 100%;
0;
transition: transform 1s;
-webkit-transform: rotateY(180deg);
-webkit-transform-origin: 100%;
0;
-webkit-transition: -webkit-transform 1s;
}
<div style="width:50%">
<div class="col-md-3 wrapper" style="position:relative;min-height:250px;">
<div class="left">sdfsdf</div>
<div class="right">sdfdsfds</div>
</div>
</div>
Your problem with transform-origin not with rotation degree, in your case:
-webkit-transform-origin: 100%; 0;
// ^ X ^ Y
That means x-axis offset 100% of div (full offset on x-axis)
No problem, Now just reset the origin to zero ( to start rotation from begin of div ) like this :
-webkit-transform-origin: 0;
Also don't forget float: right because the div will open to the left.
CSS / HTML :
.left,.right {
width:100%;
height:200px;
color:#FFF;
position:absolute;
}
.left {
background:red;
-webkit-border-top-left-radius:100px;
-webkit-border-bottom-right-radius:100px;
-moz-border-radius-topleft:100px;
-moz-border-radius-bottomright:100px;
border-top-left-radius:100px;
border-bottom-right-radius:100px;
height:250px;
border:10px solid #10832d;
padding:0;
}
.right {
background:#000;
-webkit-border-top-left-radius:100px;
-webkit-border-bottom-right-radius:100px;
-moz-border-radius-topleft:100px;
-moz-border-radius-bottomright:100px;
border-top-left-radius:100px;
border-bottom-right-radius:100px;
height:250px;
border:10px solid #10832d;
padding:0;
}
.wrapper {
perspective:1000px;
perspective-origin:100%;
-webkit-perspective:1000px;
-webkit-perspective-origin:100%;
}
.wrapper:hover .right {
transform:rotateY(180deg);
transform-origin:0;
transition:transform 1s;
-webkit-transform:rotateY(-180deg);
-webkit-transform-origin:0;
-webkit-transition:0 1s;
}
<div style="width:50%; float:right">
<div class="col-md-3 wrapper" style="position:relative;min-height:250px;">
<div class="left">left side</div>
<div class="right">right side</div>
</div>
</div>
I am trying to make one circle inside of another circle using css, but I am having an issue making it completely centered. I am close, but still not there. Any ideas?
<div id="content">
<h1>Test Circle</h1>
<div id="outer-circle">
<div id="inner-circle">
<span id="inside-content"></span>
</div>
</div>
</div>
Here is my CSS:
#outer-circle {
background: #385a94;
border-radius: 50%;
height:500px;
width:500px;
}
#inner-circle {
position: relative;
background: #a9aaab;
border-radius: 50%;
height:300px;
width:300px;
margin: 0px 0px 0px 100px;
}
Also, here is a fiddle:
http://jsfiddle.net/972SF/
Ta da!
Explained in the CSS comments:
#outer-circle {
background: #385a94;
border-radius: 50%;
height: 500px;
width: 500px;
position: relative;
/*
Child elements with absolute positioning will be
positioned relative to this div
*/
}
#inner-circle {
position: absolute;
background: #a9aaab;
border-radius: 50%;
height: 300px;
width: 300px;
/*
Put top edge and left edge in the center
*/
top: 50%;
left: 50%;
margin: -150px 0px 0px -150px;
/*
Offset the position correctly with
minus half of the width and minus half of the height
*/
}
<div id="outer-circle">
<div id="inner-circle">
</div>
</div>
You don't need extra elements in CSS3
You can do it all with one element and a box-shadow.
JSFiddle Demo.
CSS
#outer-circle {
background: #385a94;
border-radius: 50%;
height:300px;
width:300px;
position: relative;
box-shadow: 0 0 0 100px black;
margin:100px;
}
If you want to use only one div to add circle inside circle, then use box-shadow.
div {
border-radius: 50%;
box-shadow: 0px 0px 0px 10px red, 0px 0px 0px 20px green, 0px 0px 0px 30px yellow, 0px 0px 0px 40px pink;
width: 100px;
height:100px;
margin: 3em;
}
<div></div>
Solved this by using CSS transform property:
You can refer to this JS fiddle link for below output:
http://jsfiddle.net/suprabhasupi/74b1ptne/
div {
border-radius: 50%;
/* border: 1px solid red; */
}
.circle1 {
position: relative;
width: 300px;
height: 300px;
background-color: red;
}
.circle2 {
transform: translate(25%, 25%);
width: 200px;
height: 200px;
background-color: green;
}
.circle3 {
transform: translate(48%, 46%);
width: 100px;
height: 100px;
background-color: blue;
}
<div class="circle1">
<div class="circle2">
<div class="circle3">
</div>
</div>
</div>
Use position: relative on the outer circle, position:absolute on the inner circle, and set all offset to the same value. Let the automatic calculation of height and width handle the rest (JSFiddle):
#outer-circle {
position:relative;
background: #385a94;
border-radius: 50%;
height:500px;
width:500px;
}
#inner-circle {
position:absolute;
background: #a9aaab;
border-radius: 50%;
right: 100px;
left: 100px;
top: 100px;
bottom: 100px;
/* no margin, no width, they get automatically calculated*/
}
Seems that top is the only thing you need to alter -> http://jsfiddle.net/972SF/12/
#inner-circle {
position: relative;
background: #a9aaab;
border-radius: 50%;
height:300px;
width:300px;
top: 100px; /* <--- */
margin: 0px 0px 0px 100px;
}
Just use box-shadow to get the effect you want:
Demo in a fiddle: http://jsfiddle.net/972SF/16/
The html is reduced to:
<div id="content">
<h1>Test Circle</h1>
<div id="circle">
</div>
</div>
Css:
#circle {
margin: 10em auto;
background: #385a94;
border-radius: 50%;
height:200px;
width:200px;
-webkit-box-shadow: 1px 1px 0px 100px black;
-moz-box-shadow: 1px 1px 0px 100px black;
box-shadow: 1px 1px 0px 100px black;
}
its simple, easy, and makes sure that your circles are always perfectly positioned next to each other.
You can change the size of the circle by changing the 4th property ( 100px ) on box-shadow to what ever you want.
take a look at this fiddle
which calculates centering automatically
#outer-circle {
background: #385a94;
border-radius: 50%;
height:500px;
width:500px;
display:table-cell;
vertical-align:middle;
}
#inner-circle {
display:inline-block;
background: #a9aaab;
border-radius: 50%;
height:300px;
width:300px;
}
Here is an example of a circle with outer border.
HTML:
<div id="inner-circle"></div>
Styles:
#inner-circle {
background: #385a94;
border : 2px solid white;
border-radius: 50%;
height:30px;
width:30px;
position: relative;
box-shadow: 0 0 0 1px #cfd1d1;
}
See results:
JSFiddle
Try,
#inner-circle {
position: absolute;
background: #a9aaab;
border-radius: 50%;
height:300px;
width:300px;
margin: 15% 0px 0px 100px;
}
Here is ur Updated JSFIDDLE
See How I have positioned the Divs, Just border-radius should do the Job
.outer{width:500px;height:500px;background:#f00;border-radius:50%;position:relative;top:0;left:100;}
.inner{width:250px;height:250px;background:#000;border-radius:50%;position:absolute;top:125;left:125;}
<div class="outer">
<div class="inner">
</div>
</div>
DEMO
try to give the innercircle a top:50% and than margin-top: a nagative value from the half of the height of the innercircle.
http://jsfiddle.net/972SF/19/
SOLVED! Exactly the way you want:
DEMO: http://jsfiddle.net/aniruddha153/RLWua/
HTML:
<div id="content">
<div id="outer-circle">
<div id="inner-circle">
</div>
</div>
</div>
CSS:
#content {
position: relative;
width: 100%;
padding-bottom: 100%;
}
#outer-circle {
position: absolute;
width: 50%;
height: 50%;
background-color: #000000;
border-radius: 50%;
}
#inner-circle{
margin-top: 25%;
margin-left: 25%;
position: absolute;
width: 50%;
height: 50%;
background-color: #e5e5e5;
border-radius: 50%;
}
You can use the top and left property of CSS to center it.
body {
width: 100%
margin:0px;
text-align: center;
}
#content {
width: 500px;
margin-left: auto;
margin-right: auto;
}
#outer-circle {
background: #385a94;
border-radius: 50%;
height:200px;
width:200px;
}
#inner-circle {
position: relative;
background: #a9aaab;
border-radius: 50%;
height:100px;
width:100px;
top:50px;
left:50px;
}
<div id="content">
<h1>Test Circle</h1>
<div id="outer-circle">
<div id="inner-circle">
<span id="inside-content"></span>
</div>
</div>
</div>
I've been all over this site, but haven't found decent solution yet.
I'm making a photography site that has a fixed menubar div on the left and the content div flowing on the right. In the photo gallery page there should be a grid of image thumbnails with fluid margins so that the thumbnails are always evenly spaced across the right (content) div.
Here's the structure:
<body>
<div id="wrapper">
<div id="left_column">
<div class="navigation"></div>
</div>
<div id="right_column">
<div id="thumb_container" class="grayscale">
<div id="thumb_fx" ></div>
<img src="images/testimg.jpg" width="240" height="187" />
</div>
...
<div id="thumb_container" class="grayscale">
<div id="thumb_fx" ></div>
<img src="images/testimg.jpg" width="240" height="187" />
</div>
</div>
</div>
</body>
^There is a vignette roll over animation in each thumbnail.
And the CSS:
html {
height: 100%;
padding:0;
margin:0;
}
body {
height: 100%;
padding: 0;
margin: 0;
}
#wrapper {
float: left;
height: 100%;
width:100%;
padding:0;
margin:0;
}
#left_column {
position: fixed;
top: 0;
bottom: 0;
left: 0;
z-index:100;
width: 240px;
height: 100%;
overflow: hidden;
background-color:#ff0000;
}
#right_column {
background-color:#cccccc;
width:auto;
height:100%;
margin-left: 240px;
position: absolute;
}
#thumb_container {
position: relative;
max-width:50%;
min-width:240px;
height:auto;
border-color:#000000;
display: inline-block;
margin: 2%;
}
#thumb_fx {
opacity: 1;
filter: alpha(opacity=100);
-webkit-transition: opacity 0.5s linear;
transition: 0.5s;
-moz-transition: 0.5s; /* Firefox 4 */
z-index: 100;
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
background: transparent;
box-shadow:inset 0px 0px 85px rgba(0,0,0,1);
-webkit-box-shadow:inset 0px 0px 85px rgba(0,0,0,1);
-moz-box-shadow:inset 0px 0px 85px rgba(0,0,0,1);
}
#thumb_fx:hover {
opacity: 0;
filter: alpha(opacity=0);
-webkit-transition: opacity 0.5s linear;
transition: 0.5s;
-moz-transition: 0.5s; /* Firefox 4 */
}
.grayscale img{
max-width:100%;
min-width:50%;
height:auto;
position: relative;
border:none;
z-index: -1;
position: relative;
}
The best solution so far is this: http://jsfiddle.net/VLr45/1/ but the margins go way too tight before the div is dropped to the next row. And I don't understand how to adjust them.
Any help?
When you calculate the number of boxes that will fit, add the minimum margin you would like:
Margin as pixels
var boxMinMargin = 10; // 10px
var columns = Math.floor(parent / (box + boxMinMargin));
http://jsfiddle.net/VLr45/14/
Margin as %
var boxMinMargin = box * 0.1; // 10% of box
var columns = Math.floor(parent / (box + boxMinMargin));
http://jsfiddle.net/VLr45/24/
If you prefer to set the margin with css, you can set the width in you box class
.box {
margin: 2%;
/*
or
margin-top: 2%;
margin-right: 3%;
margin-bottom: 4%;
margin-left: 5%;
*/
}
http://jsfiddle.net/VLr45/17/
This is my code
CSS
#page {
width: 900px;
padding: 0px;
margin: 0 auto;
direction: rtl;
position: relative;
}
#box1 {
position: relative;
width: 500px;
border: 1px solid black;
box-shadow: -3px 8px 34px #808080;
border-radius: 20px;
box-shadow: -8px 5px 5px #888888;
right: 300px;
top: 250px;
text-align: justify;
-webkit-transition: all .75s;
font-size: large;
color: Black;
padding: 10px;
background: #D0D0D0;
opacity: 0;
}
#-webkit-keyframes myFirst {
0% {
right: 300px;
top: 160px;
background: #D0D0D0;
opacity: 0;
}
100% {
background: #909090;
:;
right: 300px;
top: 200px;
opacity: 1;
}
}
#littlebox1 {
top: 200px;
position: absolute;
display: inline-block;
}
.littlebox1-sentence {
font-size: large;
padding-bottom: 15px;
padding-top: 15px;
padding-left: 25px;
padding-right: 10px;
background: #D0D0D0;
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
-webkit-transition: background .25s ease-in-out;
}
#bothcontainer:hover ~ #box1 {
-webkit-transition: all 0s;
background: #909090;
:;
right: 300px;
top: 200px;
-webkit-animation: myFirst .75s;
-webkit-animation-fill-mode: initial;
opacity: 1;
}
#bothcontainer:hover .littlebox1-sentence {
background: #909090
}
#bothcontainer:hover .triangle {
border-right: 25px solid #909090
}
.triangle {
position: relative;
width: 0;
height: 0;
border-right: 25px solid #D0D0D0;
border-top: 27px solid transparent;
border-bottom: 24px solid transparent;
right: 184px;
-webkit-transition: border-right .25s ease-in-out;
}
HTML
<body dir="rtl">
<div id="page">
<div id="bothcontainer">
<div id="littlebox1" class="littlebox1-sentence">put your mouse here</div>
<div id="littlebox1" class="triangle"></div>
</div>
<div id="box1"></div>
</div>
I want to add a border to the triangle, to .littlebox1-sentence.
The border will not change its color.
Here is a fiddle
I have come closer to finding the solution, but it still is not where I want it.
Fiddle
I'm not exactly sure what effect you're after, but I'd have a look at -webkit-filter. It allows you to add a shadow to "this element and any children it has, regardless of shape".
#littlebox1 {
top: 200px;
position: absolute;
display: inline-block;
-webkit-filter: drop-shadow(green -10px 0 10px);
}
http://jsfiddle.net/DyxA4/
Another solution: skip the border-based triangle and use three divs instead:
<div class="sign">
<div class="arrow"><div></div></div>
<p>Lorem ipsum dolor</p>
</div>
Basically, we use ".arrow div" to create the triangle, and ".arrow" the cut off the bits we don't need:
http://jsfiddle.net/k5J6M/1/
The triangle IS the border. You can't do what you're asking. Just make an image.