Need to draw Circle with CSS like this [duplicate] - html

This question already has answers here:
Border radius circle
(6 answers)
how to put img inside circle in html and css?
(4 answers)
Closed 12 months ago.
Need to draw circle onto which I place image icon like this by applying CSS as shown in image below. Tried the code but unable to accomplish it. Please help.
Required:
HTML:
.dot {
height: 505px;
width: 25px;
background-color: #bbb;
border-radius: 50%;
display: inline-block;
}
<div style="text-align:center">
<h1>Round Dots / Circles</h1>
<span class="dot"></span>
</div>

i have create as you want. please check. if this helpful please hit the green check. thanks
.dot {
height: 200px;
width: 200px;
background-color: #fff;
border-radius: 50%;
border: 5px solid grey;
display: inline-block;
text-align:center;
}
.dot h3 {
font-size: 23px;
margin:0;
}
.dot-box {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
height: 100%;
}
.dot2 {
display: table;
}
.dot-box2 {
display: table-cell;
vertical-align: middle;
}
<h2>
Circle With Flex
</h2>
<div class="dot">
<div class="dot-box">
<img src="https://i.ibb.co/QcHsj9z/user.jpg">
<h3>
MEMBER FEATURE
</h3>
</div>
</div>
<br>
<h2>
Circle With Table
</h2>
<div class="dot dot2">
<div class="dot-box2">
<img src="https://i.ibb.co/QcHsj9z/user.jpg">
<h3>
MEMBER FEATURE
</h3>
</div>
</div>

Make the width and height the same
.dot {
height: 50px;
width: 50px;
background-color: #bbb;
border-radius: 50%;
display: inline-block;
}
<div style="text-align:center">
<h1>Round Dots / Circles</h1>
<span class="dot"></span>
</div>

For A Circle, Height and Width should be same.
.dot {
height: 200px;
width: 200px;
background-color: #bbb;
border-radius: 50%;
// Below Code is For Placing content in the Center of Circle
display: flex;
flex-direction:column;
justify-content: center;
align-items:center;
}
<div class="dot">
<div class="content">
<h1>Round Dots / Circles</h1>
</div>
</div>

Height should be same as width.
.dot {
height: 505px;
width: 505px;
background-color: #bbb;
border-radius: 50%;
display: inline-block;
}
<div style="text-align:center">
<h1>Round Dots / Circles</h1>
<span class="dot"></span>
</div>

Here is the code pen link:
https://codepen.io/wahabshah/pen/YzELexr
.dot {
height: 200px;
width: 200px;
background-color: #bbb;
border-radius: 50%;
border: 5px solid grey;
display: inline-block;
}
Also for inside content use display : flex and use column for displaying them vertically.

Height and width must be equal to form a circle and border-radius of 50%

Related

How do you center an element w.r.t an already centered element in flex?

[![Red: Centered on canvas: Black: Centered between center and top of canvas][1]][1]
Using flex, it is easy to position elements in the center of a div. But how can this be done relative to already centered elements, using flex?
Shown below in the code is the best I've come up so far. I am able to center the red square in the middle but cannot get the blue one above it to be vertically center-aligned between the red square and the top border.
.flex {
border-style: solid;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background-color: white;
height: 100vh
}
.square {
height: 10px;
width: 10px;
}
#square1 {
background-color: blue;
}
#square2 {
background-color: red;
}
.flexdivider {
display: flex;
flex-direction: column
justify-content: center;
align-items: center;
flex: 1;
}
p {
color: white;
}
<body>
<div class="flex">
<div class="flexdivider">
<div class="square" id="square1"></div>
</div>
<div class="flexdivider">
<div class="square" id="square2"></div>
</div>
<div class="flexdivider">
</div>
</div>
</div>
</body>
[1]: https://i.stack.imgur.com/4lUop.png
I have created 2 separated approach.
h2{
color: #333;
}
.box,.fakebox{
width: 30px;
height: 30px;
background-color: red;
}
/* Example #1 */
.container-box-1{
background-color: #eee;
width: 300px;
height: 300px;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
position: relative;
}
.fakebox{
opacity: 0;
}
.box2{
position: absolute;
top: 25%;
left: 50%;
transform: translate(-50%,-50%)
}
<h2>Example #1 (Using Display Flex and position absolute)</h2>
<div class="container-box-1">
<div class="box"></div>
<div class="box box2"></div>
</div>

Image with solid color rounded background

I want to display images inside a container that has a colored background.
I want the background of the container is rounded, and the image is placed at the center.
Also, there is space between the border of the background and the image.
This is the goal:
img
The code so far:
.circle{
border-radius: 50%;
background: #2e374f;
display: flex;
justify-content: center;
align-items: center;
height: 50px;
width: 50px;
display: table-cell;
vertical-align: middle;
}
.title{
color: #ffffff;
font-size: 10px;
text-align: center;
margin-top: 5px;
opacity: 0.5;
}
<div class="circle">
<img src="https://www.fillmurray.com/50/50" class="mx-auto d-block">
<div class="title">
TITLE
</div>
</div>
this is what I achieved so far:
img
you need to remove display: table-cell rule and additionaly you can shrink the image.
.circle{
border-radius: 50%;
background: #2e374f;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 150px;
width: 150px;
}
.title{
color: #ffffff;
font-size: 10px;
text-align: center;
margin-top: 5px;
opacity: 0.5;
}
.img {
max-width: 50%;
max-height: 50%;
}
<div class="circle">
<img src="https://picsum.photos/100/100?grayscale" class="mx-auto d-block img">
<div class="title">
TITLE
</div>
</div>
Please check.
.container-box {
width: 400px;
height: 400px;
background-color: black;
}
.container-circle {
display:inline-block;
margin: 50px;
width: 300px;
height: 300px;
border-radius: 150px;
background-color: gray;
}
.image {
background: url(https://upload.wikimedia.org/wikipedia/commons/c/ce/Font_Awesome_5_solid_arrow-circle-right.svg);
width: 100px;
height: 100px;
display: inline-block;
margin: 100px;
}
<div class="container-box">
<div class="container-circle">
<div class="image">
</div>
</div>
</div>
`
If I see correctly you want the image to be round and not the container. In this case this should help you out:
.circle img {
border-radius: 50%;
max-width: 100%;
}
.circle{
background: #2e374f;
display: flex;
justify-content: center;
align-items: center;
flex-flow: column;
height:100px;
width: 100px;
}
.title{
color: #ffffff;
font-size: 10px;
text-align: center;
margin-top: 5px;
opacity: 0.5;
}
<div class="circle">
<img src="https://www.fillmurray.com/50/50" class="mx-auto d-block">
<div class="title">
TITLE
</div>
</div>

How do I make border-radius in radio buttons? [duplicate]

This question already has answers here:
How to make CSS3 rounded corners hide overflow in Chrome/Opera
(12 answers)
Should border-radius clip the content?
(6 answers)
Closed 2 years ago.
How do I make border-radius in radio buttons?
How do I apply border-radius to the box class?
.box {
width: 300px;
height: 60px;
background: red;
display: flex;
align-items: center;
border-radius: 50px;
}
.item {
width: 100%;
height: 100%;
background: #000;
display: flex;
color: red;
justify-content: center;
align-items: center;
}
.item_active {
background: gray;
}
<div class="box">
<div class="item_active item">1</div>
<div class="item">2</div>
<div class="item">3</div>
</div>
I set it to 50px, but for some reason it doesn't work.
you need to add overflow hidden to .box class, so that the border radius cuts the underlaying content.
.box {
width: 300px;
height: 60px;
background: red;
display: flex;
align-items: center;
border-radius: 50px;
overflow: hidden;
}
.item {
width: 100%;
height: 100%;
background: #000;
display: flex;
color: red;
justify-content: center;
align-items: center;
}
.item_active {
background: gray;
}
<div class="box">
<div class="item_active item">1</div>
<div class="item">2</div>
<div class="item">3</div>
</div>

CSS responsive circles

How can I align center an icon and text (below icon), so that they stay at the same position inside a rectangular div when it's getting resized? Here is the example of what I meant. Example
.card{
width: 300px;
height: 400px;
border: 1px solid skyblue;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.circle{
width: 30px;
height: 30px;
border-radius: 100%;
background: green;
}
<div class="card">
<span class="circle"></span>
</div>
Try to use display: flex

Bug w html/css/divs centering text w/ flexbox despite using similar model throughout the site

So I have been been centering my code using flexbox in CSS no problem throughout this site I am working on for practice/fun but I have run into what appears to be an inconsistency I havnt been able to debug.
I two div boxes within two larger parent divs. The div boxes sit side by side and within I have circle divs I am trying to place gliphicons and text directly in the middle while ensuring the circle divs radius integrity is not compromised. Please let me know if you have any insights. (gliphicon seems out of place thematically but I'm just trying to debug)
Below I have HTML and CSS snippets:
.item1 {
height: 600px;
width: 49.5%;
margin: 1px;
color: white;
text-align: center;
line-height: 50px;
font-weight: 600;
background-color: #E2E2E2;
display: flex;
align-items: center;
justify-content: center;
}
.circle {
border-radius: 50%;
width: 50%;
height: auto;
padding-top: 50%;
border: 1px solid black;
/*background: #ef8913;*/
display: flex;
align-items: center;
justify-content: center;
text-align: center;
}
<div class="example-content">
<div class="parent0">
<div class="item1">
<div class="circle">
<h2><i class="fa fa-shopping-bag" aria-hidden="true"> </i>Ride Your Bike Bareass <br> Through The Desert!</h2>
</div>
</div>
<div class="item0">
<div class="circle"></div>
</div>
</div>
</div>
If I am reading your question correctly..
The width / height and padding was your enemy.. Here's what I have done:
.item1 {
height: 600px;
width: 100%;
margin: 1px;
color: white;
text-align: center;
line-height: 50px;
font-weight: 600;
background-color: #E2E2E2;
display: flex;
align-items: center;
justify-content: center;
}
.circle {
border-radius: 50%;
width: 70%;
height: 100%;
border: 1px solid black;
/*background: #ef8913;*/
display: flex;
align-items: center;
justify-content: center;
}
<div class="example-content">
<div class="parent0">
<div class="item1">
<div class="circle">
<h2><i class="fa fa-shopping-bag" aria-hidden="true"> </i>Ride Your Bike Bareass <br> Through The Desert!</h2>
</div>
</div>
</div>
</div>
You may need to tweak the .circle width % to make it accurate but these would be the lines to go down.
remove padding-top from .circle and give padding to all sides
.item1 {
height: 600px;
width: 49.5%;
margin: 1px;
color: white;
text-align: center;
line-height: 50px;
font-weight: 600;
background-color: #E2E2E2;
display: flex;
align-items: center;
justify-content: center;
}
.circle {
border-radius: 50%;
width: 50%;
height: auto;
padding: 2em 1em;
border: 1px solid black;
/*background: #ef8913;*/
display: flex;
align-items: center;
justify-content: center;
text-align: center;
}
<div class="example-content">
<div class="parent0">
<div class="item1">
<div class="circle">
<h2><i class="fa fa-shopping-bag" aria-hidden="true"> </i>Ride Your Bike Bareass <br> Through The Desert!</h2>
</div>
</div>
</div>
</div>