Circle div balloon - html

Here is my current css for image circle baloon
.circle-image{
width: 64px;
height: 64px;
border-radius: 50%;
background-size: contain;
background-position: center;
background-image: url("/assets/img/dashboard/img-stdn.png");
display: block;
}
And the div output as below:
How I can border the div and become like this?
Let say the image inside the div :

You could use a pseudo element in order to create your speech bubble triangle, as shown in the demo below.
This works by using a skew on a square, and position it absolutely within a relatively positioned container element.
Alternatively, this could be achieved with a single element if you were able to use the background-image instead of an image tag.
.circ {
height: 100px;
width: 100px;
border-radius: 50%;
bordeR: 5px solid tomato;
position: relative;
}
.circ img {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
border-radius: 50%;
}
.circ:before{
content:"";
position:absolute;
top:10%;
right:0;
height:20px;
width:20px;
background:tomato;
transform:skewX(55deg) skewY(10deg);
}
<div class="circ">
<img src="http://i.stack.imgur.com/lCp2t.png" />
</div>
for more info in generating the triangle, you may find this quite a useful demonstration of how to achieve this triangle.
Background-image
By using a background-image instead, you can make this with only a single element.
.circ {
position: relative;
height: 100px;
width: 100px;
border-radius: 50%;
border: 5px solid tomato;
background:url(http://i.stack.imgur.com/lCp2t.png);
background-size:100% 100%;
}
.circ:before{
content:"";
position:absolute;
top:10%;
right:0;
height:20px;
width:20px;
background:tomato;
transform:skewX(55deg) skewY(10deg);
z-index:-1;
}
<div class="circ"></div>

If you're looking for the arrow, this is what you need to add.
http://jsfiddle.net/c3Love5c/1/
.circle-image{
width: 64px;
height: 64px;
border-radius: 50%;
background-size: cover;
background-position: center;
background-image: url("http://i.stack.imgur.com/lCp2t.png");
display: block;
border:3px solid purple;
position:relative;
}
.circle-image:before{
content:'';
display:block;
border:10px solid transparent;
border-top-color:purple;
position:absolute;
right:-5px;
top:5px;
transform:rotate(15deg);
-moz-transform:rotate(15deg);
-webkit-transform:rotate(15deg);
-ms-transform:rotate(15deg);
-o-transform:rotate(15deg);
}

Related

css image with border-radius

I am trying to replicate this style, which has a background image, on the other hand I have a div over it that has a right border-radius, I can't do it, I provided the following options adapting them, but I couldn't
enter image description here
Transparent hollow or cut out circle
div{
position:relative;
width:500px; height:200px;
margin:0 auto;
overflow:hidden;
}
div:after{
content:'';
position:absolute;
left:175px; top:25px;
border-radius:100%;
width:150px; height:150px;
box-shadow: 0px 0px 0px 2000px #E3DFD2;
}
body{background: url('https://farm9.staticflickr.com/8760/17195790401_ceeeafcddb_o.jpg';
Background with radius-top inside
div {
background:lightgreen;
width:100%;
height:200px;
position:relative;
text-align:center;
padding:100px 0 0 0;
box-sizing:border-box;
}
div:before {
content:'';
position:absolute;
background:white;
width:100%;
height:100px;
top:0;
left:0;
border-radius:40%;
transform:translatey(-50%);
}
The cut out example with the circle suits fine, You just need to play around with the values in the DevTools/Inspector.
Adjust heights/widths of the :before to stretch the curve to your liking or even mess with % of border radius, then the border width for how much space around it, the top and left to position it to the edges, then use the parent container to trim off right and bottom areas.
.banner {
background: url(https://farm9.staticflickr.com/8760/17195790401_ceeeafcddb_o.jpg);
background-size: cover;
}
.shape {
position: relative;
width: 170px;
height: 440px;
overflow: hidden;
}
.shape:after {
content: '';
position: absolute;
left: -100px;
top: -200px;
border-radius: 100%;
width: 151px;
height: 440px;
border: 200px solid #ffffff;
}
<div class="banner">
<div class="shape">
</div>
</div>
you can do this by clip-path property ..
Note : minimum width required otherwise shape will not display
*{
box-sizing: border-box;
margin: 0;
padding: 0;
}
.container {
width: 100%;
margin: 0 auto;
display: flex;
}
.left{
width: 10%;
}
.image {
width: 90%;
height: 400px;
overflow: hidden;
background: url(https://farm9.staticflickr.com/8760/17195790401_ceeeafcddb_o.jpg);
background-size: cover;
clip-path: circle(100% at 100% 50%);
}
<div class="container">
<div class="left">
</div>
<div class="image">
</div>
</div>

Center absolute div under its parent using percentages not absolute values

This, this, and this question were similar but did not help.
The goal is to center an element under its parent using percentages, not absolute values. This way, position values do not need to change if sizes change.
The hover element below is centered under outer, but positioning requires absolute values that depend on the sizes of hover and outer. If either change, the position values must change.
Can centering underneath a parent be achieved with percentages?
Codepen: https://codepen.io/anon/pen/dadjpg
<div id="outer">
<div id="hover"></div>
</div>
#outer {
width: 200px;
height: 200px;
background: blue;
position: relative;
}
#hover {
width: 50px;
height: 50px;
background: yellow;
position: absolute;
margin: auto;
left: 75px;
bottom: -50px;
}
You can also use top:100%; left:0px; right:0px; margin:0px auto;
#outer {
width: 200px;
height: 200px;
background: blue;
position: relative;
}
#hover {
width: 50px;
height: 50px;
background: yellow;
position: absolute;
left:0px;
right:0px;
top:100%;
margin:0px auto;
}
<div id="outer">
<div id="hover"></div>
</div>
You can use top:100% to move the element to the bottom then simply combine left:50% with translateX(-50%) to center:
#outer {
width: 200px;
height: 200px;
background: blue;
position: relative;
}
#hover {
width: 50px;
height: 50px;
background: yellow;
position: absolute;
left:50%;
transform:translateX(-50%);
top:100%;
}
<div id="outer">
<div id="hover"></div>
</div>
Same logic considering bottom:0
#outer {
width: 200px;
height: 200px;
background: blue;
position: relative;
}
#hover {
width: 50px;
height: 50px;
background: yellow;
position: absolute;
bottom:0;
left:50%;
transform:translate(-50%,100%);
}
<div id="outer">
<div id="hover"></div>
</div>
Another idea is to consider flexbox to center inside the element then translate to make the element outside:
#outer {
width: 200px;
height: 200px;
background: blue;
position: relative;
display:flex;
}
#hover {
width: 50px;
height: 50px;
background: yellow;
margin:auto auto 0;
transform:translateY(100%);
}
<div id="outer">
<div id="hover"></div>
</div>

Make the top and bottom borders curved and dropshadow at the bottom?

I'm trying to create something like this:
enter image description here
My code is like this which only curves the bottom border and I cannot put any content in it and it hasn't got any bottom dropshadow either:
.curvedbox {
position:fixed;
top:0; left:0;
width:100%;
background:none;
height:10%;
padding-bottom:20%;
overflow:hidden;
z-index:1;
}
.curvedbox:after {
content:'';
position:absolute;
left:-600%;
width:1300%;
padding-bottom:2300%;
top:80%;
background:none;
border-radius:50%;
box-shadow: 0px 0px 0px 9999px #526375;
z-index:-1;
<div class="curvedbox"></div>
Could someone please advice on this?
Thanks in advance.
Consider separating the content into three parts:
Part 1: element for the upper or outer curve
Part 2: an element to specifically contain any content
Part 3: an element for the lower or inner curve (which we'll declare
an inset box-shadow property to)
Nest these parts within a containing element, as demonstrated with the code snippet embedded below.
Code Snippet Demonstration:
* {
box-sizing: border-box;
font-family: arial;
}
.containing-curves {
position: fixed;
top: 0;
left: 0;
width: 100%;
max-width: 300px;
background: none;
overflow: hidden;
}
.inner-curve {
height: 50px;
border-top-left-radius: 100%;
border-top-right-radius: 100%;
background: #d2d2d2;
position: absolute;
left: 0;
right: 0;
bottom: -25px;
box-shadow: inset 1px 1px 5px 3px #505050;
}
.inner-content {
display: flex;
justify-content: space-evenly;
height: 100%;
align-items: center;
background: gray;
position: relative;
margin-top: 25px;
padding-bottom: 25px;
}
.outer-curve {
height: 50px;
border-top-left-radius: 100%;
border-top-right-radius: 100%;
background: #808080;
position: absolute;
top: 0;
left: 0;
right: 0;
}
.inner-content span {
width: 100%;
text-align: center;
}
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.css">
<div class="containing-curves">
<div class="outer-curve"></div>
<div class="inner-content">
<span><i class="fa fa-cloud"></i></span>
<span>text</span>
<span><small>text</small><br><small>text</small></span>
</div>
<div class="inner-curve"></div>
</div>
If you are open to a different way of doing it...
.curvedbox {
position:fixed;
top:0;
left:0;
width:100%;
background:none;
height:10%;
padding-bottom:20%;
overflow:hidden;
z-index:1;
}
.curvedbox:before, .curvedbox:after{
content:'';
position:absolute;
top:0;
left:50%;
transform:translateX(-50%);
width:1200%;
height:0;
padding-bottom:1300%;
border-radius:50%;
}
.curvedbox:before {
background-color:#526375;
}
.curvedbox:after {
top:90%;
background-color:white;
}
<div class="curvedbox"></div>
It's hacky and the top value of .curvedbox:after might need to be changed depending on your needs.

Creating a circular border radius on multiple child components

so what i am trying to do is have a circle which inside of it, contains an image and a description which overlays the image at 50% Opacity. Heres the result so far:
So, obviously, i want the entire div to have this border-radius, and so far have had to set the parent and img components to have this certain border-radius. What i was wondering was how to have all elements with a circular radius,
(bonus points possibly using border-radius: XX% and not border-radius: XXpx;). Heres what i have tried so far:
JSX
return(
<div className="container">
<img src={this.props.src} alt=""/>
<div className="descriptor">
<h4>{this.props.title}</h4>
</div>
</div>
);
CSS
.container{
margin: 20px;
height: 200px;
width: 200px;
border-radius: 20px;
position: relative;
border-radius: 100px;
display: inline-block;
border-radius:100px;
border:2px solid red;
}
.container img{
max-width:100%;
border-radius:100px;
float: left;
}
.descriptor{
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 30%;
background-color: black;
display: flex;
flex-direction: column;
justify-content: center;
color: white;
opacity: 0.5;
/*NOTE: Here i have tried using things like border-bottom-left-radius: 750px;
But yeah that didnt work*/
}
Here's a demonstration with the comments for the appropriate CSS style attributes.
.roundc{
width:300px; /*Width and height need to be equal for border radius*/
height:300px; /*50% to work and make the square circular */
display:inline-block;
border-radius: 50%; /*Make the container circular */
border:3px solid red;
overflow: hidden; /*Hide the content overflow */
position:relative; /*To use absolute positioning on img*/
}
.roundc img{ /*To center the large image */
position:absolute;
top:50%;
left:50%;
transform: translate(-50%,-50%);
}
.roundc span{
position:absolute;
z-index:1;
background:red;
color:white;
width:300px;
height:30px;
text-align:center;
bottom:0;
}
<div class="roundc">
<img src="http://via.placeholder.com/350x350">
<span> About me </span>
</div>

How to arrange div structure with radius using CSS

I am trying to create HTML page shown in this sample image.
I want to place other component on top of this black and maroon circles. For this I am using tag Structure of div and span. And using span background-image to apply this image as background.
My problem is what will be structure of div and span to arrange black circle on radius of div/span tags containing maroon circle as background.
Till now I have center circle placed. I don't know how to arrange other circles around it
div.table-text {
position: fixed;
top: 20%;
left: 20%
}
span.table-text {
position: inherit;
display: block;
width: 60%;
height: 60%;
background-image: url(../images/table-text.png);
background-position: bottom;
background-repeat: no-repeat;
}
<div class="table-text">
<span class="table-text">
</span>
</div>
Im not sure I understood the question, but I'll try to answer.
You can't use something like cos() to arrange elements on HTML, you will have to use negatives margin-top: or position: absolute;
My advise: use negative margins, for the black dots on the left and right.
Edit: I did your job, now pay me! #:
.circle {
display: inline-block;
border-radius: 200px;
position: absolute;
width: 100px;
height: 100px;
background-color: black;
}
#bigCircle {
border-radius: 200px;
width: 400px;
height: 400px;
margin: 0 auto;
background-color: brown;
}
#bottom {
margin: 50px calc(50% - 50px);
}
#left {
margin: -50px calc(25% - 50px);
}
#right {
margin: -50px calc(75% - 50px);
}
<div id="bigCircle"></div>
<div class="circle" id="left"></div>
<div class="circle" id="bottom"></div>
<div class="circle" id="right"></div>
JSFiddle - DEMO
Without knowing the rest of your document structure, I've thrown together this proof of concept for you using absolute positioning which should, hopefully, point you in the right direction.
If you need clarification on anything or any of it doesn't suit your needs, please let me know and I'll attempt to update it accordingly.
*{
box-sizing:border-box;
color:#fff;
font-family:sans-serif;
}
.top{
background:red;
border-radius:50%;
margin:-10% auto 0;
padding:0 0 75%;
position:relative;
width:75%;
}
div>div{
background:green;
border-radius:50%;
overflow:hidden;
padding:0 0 20%;
position:absolute;
width:20%;
}
div.one{
left:-10%;
top:80%;
}
div.two{
left:40%;
top:103%;
}
div.three{
right:-10%;
top:80%;
}
p{
text-align:center;
position:absolute;
margin:0;
width:100%;
}
.top>p{
top:15%
}
.top>div>p{
top:5%;
}
<div class="top">
<p>top</p>
<div class="one">
<p>one</p>
</div>
<div class="two">
<p>two</p>
</div>
<div class="three">
<p>three</p>
</div>
</div>
I think you want like here
for responsive you can use value in percentages or max-width.
<div class="maroon">
<div class="m-child m-child1"></div>
<div class="m-child m-child2"></div>
<div class="m-child m-child3"></div>
<div class="m-child m-child4"></div>
</div>
.maroon{
max-width: 300px;
max-height:300px;
background:maroon;
top:0;
right:0;
bottom:0;
left:0;
margin:auto;
}
.m-child, .maroon{
position: absolute;
border-radius:100%;
}
.m-child{
background: #000;
width:100px;
height:100px;
}
.m-child1{
left: -50px;
top:0;
bottom: 0;
margin: auto;
}
.m-child2{
right: -50px;
top:0;
bottom: 0;
margin: auto;
}
.m-child3{
top: -50px;
left: 0;
right:0;
margin: auto;
}
.m-child4{
bottom: -50px;
left: 0;
right:0;
margin: auto;
}
I think you need something like following: You can make changes as per your requirement.
.middle_circle {
background: none repeat scroll 0 0 red;
border-radius: 100%;
height: 200px;
left: 220px;
position: absolute;
top: 60px;
width: 200px;
}
.circle{
position:relative;
width:5%;padding-bottom:50%;
margin-left:47.5%;
}
.circle div {
position:absolute;
top:0; left:0;
width:100%; height:100%;
-webkit-transform : rotate(24deg);
-ms-transform : rotate(24deg);
transform : rotate(24deg);
}
.circle:before, .circle div:before {
content:'';
position:absolute;
top:0; left:0;
width:100%; padding-bottom:100%;
border-radius: 100%; background:black;
}
<div class="circle">
<div><div><div><div><div><div><div><div><div><div><div><div><div><div><div>
</div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
</div>
<div class="middle_circle"></div>
Check Fiddle.