CSS styling shape [duplicate] - css

This question already has answers here:
CSS Only Pie Chart - How to add spacing/padding between slices?
(2 answers)
HTML5 / CSS3 Circle with Partial Border
(8 answers)
Closed 2 years ago.
I'm trying to create this image: https://i.stack.imgur.com/7k4Uq.png
I'm not sure what the best way to do this is. I got the CSS to work, but I don't know if there is a "better way" of doing it, or a cleaner/easier method. My CSS is below:
:root{
--size-red: 70px;
--size-grey: 43px;
}
.arc {
width: 0;
height: 0;
position: relative;
border-left: var(--size-red) solid transparent;
border-right: var(--size-red) solid transparent;
border-top: 100px solid red;
border-radius: 51%;
}
.arc:after {
content:'';
width: 0;
height: 0;
position: relative;
right: var(--size-grey);
border-left: var(--size-grey) solid transparent;
border-right: var(--size-grey) solid transparent;
border-top: 60px solid white;
border-radius: 51%;
}
Any suggestions for how to make my code look cleaner/more manageable would be appreciative. Thanks!

Related

How to do I make Talk Bubble shape in CSS? [duplicate]

This question already has answers here:
How do CSS triangles work?
(23 answers)
Closed 11 months ago.
I'm trying to make this shape in HTML/CSS, and I can't do it for the life of me. If anyone can give a heads-up, it would be much appreciated. Including JS also doesn't matter. If you can give the smallest nudge in the right direction, I would be grateful. Thanks, here's the drawing.
Please check this code
#talkbubble {
width: 120px;
height: 80px;
background: red;
position: relative;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
}
#talkbubble:before {
content:"";
position: absolute;
right: 100%;
top: 26px;
width: 0;
height: 0;
border-top: 13px solid transparent;
border-right: 26px solid red;
border-bottom: 13px solid transparent;
}
<div class="shape">
<h2>Talk Bubble</h2>
<div id="talkbubble"></div>
</div>

CSS Rectangle with one corner not connected [duplicate]

This question already has answers here:
Any way to declare a size/partial border to a box?
(6 answers)
Closed 1 year ago.
Trying to replicate this design using css. The quotes are pngs. But can only find help for solid rectangles and more of a page corner folded to save a spot.Design I'm trying to replicate with Css
I gave them different colors so you could visualize what's happening easily.
.myDiv {
margin-top: 30px;
position: relative;
width: 50px;
height: 50px;
background-color: transparent;
border: 10px solid red;
border-radius: 0 0 15px 15px;
border-top: none;
}
.myDiv::before {
content: '';
position: absolute;
height: 20px;
width: 40px;
background-color: orange;
top:-10px;
left:20px;
border-radius: 0 10px 0 0;
}

CSS for text inside a ribbon/pennant type shape [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Im looking to replicate something like this but as a relatively new guy to CSS, I cannot for the life of me figure out the appropriate CSS to create this shape around the text.
image example
Really appreciate any help you can give. Thanks in advance!
There are multiple ways to do this. But you can split it in 2 separate shapes.
Rectangular shape ( background of the text ) and a triangle using a pseudo element.
See below
Tweak around with the border values of the after element to achieve exactly the shape you want.
span {
position:relative;
color: white;
background: blue;
padding: 10px 0 10px 10px;
margin-top: 10px;
display: inline-block;
}
span:after {
width: 0;
height: 0;
border-top: 19px solid transparent;
border-bottom: 19px solid transparent;
border-left: 20px solid blue;
position: absolute;
right: 0;
transform: translateX(100%);
content: '';
top: 0;
}
<span>
My Text
</span>
There you go
Note that you can play around with the border-left value in #snippet:after to increase or reduce the "arrow section"
#snippet {
width: 200px;
height: 150px;
background-color: red;
position: relative;
}
#snippet:after {
content: '';
position: absolute;
top: 0px;
left: 200px;
border: 75px solid transparent;
border-left: 30px solid red;
}
<div id="snippet">Hello</div>

Triangles at the corners of a DIV [duplicate]

This question already has answers here:
Rectangle with two cut edges
(6 answers)
Div with cut out edges, border and transparent background
(6 answers)
Cut Corners using CSS
(16 answers)
Closed 3 years ago.
I am trying to build a DIV with cut corners, like so:
I only managed to do the top right corner using a tutorial and here is the code:
.lifeatblock {
background-color: #435973 !important;
position:relative;
}
.lifeatblock:after {
content: '';
border-style: solid;
border-width: 0 50px 50px 0;
border-color: transparent #fff transparent transparent;
width: 0;
height: 0;
right: 0;
top: 0;
position: absolute;
}
I've tried building the bottom left corner using :before and I've failed. Does anyone know how I can do this? Thanks.
it can be done with pseudo element like this!
*{
margin:0;
padding:0;
}
.box{
background-color:blue;
width:400px;
height:200px;
position:absolute;
top:50%;
left:50%;
transform:translate(-50%,-50%)
}
.box:before, .box:after{
content:"";
position:absolute;
width: 0;
height: 0;
border-left: 30px solid transparent;
border-right: 30px solid transparent;
border-bottom: 30px solid white;
}
.box:before{
transform:rotate(-135deg);
left:-20px;
bottom:-12.5px;
} .box:after{
transform:rotate(45deg);
right:-20px;
top:-12.5px;
}
<div class="box"></div>

Trying to get border to stay on bottom

Soo ive tried this code
.itemselected {
Width: 150px;
height: 150px;
border-bottom: 1px solid #111;
}
But when i use that it loks very weird like theres a border around the Whole thing, i only want the border at the bottom.
.itemselected {
Width: 150px;
height: 150px;
border-bottom: 1px solid #111;
border-top: 0;
border-left: 0;
border-right: 0;
}
That should fix it, i had the same problem before but when i used that code to set the other borders to 0 it worked perfectly :)

Resources