How to control CSS arrow size - html

I created an arrow in CSS. Everything is working as it should except the size of the arrow. I am not sure how I can make it smaller.
How can I make the arrow smaller?
#blue {
width: 100%;
height: 100vh;
background: blue;
}
#box2 {
position: absolute;
top: 25%;
right: 25%;
z-index: 1;
}
#box2Text {
color: #FFF;
font-family: 'Muli', sans-serif;
font-size: 2rem;
font-weight: 300;
line-height: 1.4em;
padding: 80px;
border: 6px solid #FFF;
border-radius: 2px;
display: block;
text-align: center;
}
#arrow {
margin-top: 10px;
border: solid #FFF;
border-width: 0 3px 3px 0;
display: block;
padding: 3px;
transform: rotate(45deg);
-webkit-transform: rotate(45deg);
}
<section id="blue">
<div id="box2">
<span id="box2Text">View Services</span>
<div id="arrow"></div>
</div>
</section>
Desired output:

Use the arrow as a pseudo element of the text div and you can easily place it and adjust its size:
#blue {
width: 100%;
height: 100vh;
background: blue;
}
#box2 {
position: absolute;
top: 25%;
right: 25%;
z-index: 1;
}
#box2Text {
color: #FFF;
font-family: 'Muli', sans-serif;
font-size: 2rem;
font-weight: 300;
line-height: 1.4em;
padding: 80px;
border: 6px solid #FFF;
border-radius: 2px;
display: block;
text-align: center;
position:relative;
}
#box2Text:after {
content:"";
left:calc(50% - 5px);
margin-top:40px;
position:absolute;
border: solid #FFF;
border-width: 0 3px 3px 0;
width:10px;
height:10px;
transform: rotate(45deg);
}
<section id="blue">
<div id="box2">
<span id="box2Text">View Services</span>
</div>
</section>

You just need to specify CSS width and height attributes to #arrow. you might need to adjust the arrow position after that according to your needs
#blue {
width: 100%;
height: 100vh;
background: blue;
}
#box2 {
position: absolute;
top: 25%;
right: 25%;
z-index: 1;
}
#box2Text {
color: #FFF;
font-family: 'Muli', sans-serif;
font-size: 2rem;
font-weight: 300;
line-height: 1.4em;
padding: 80px;
border: 6px solid #FFF;
border-radius: 2px;
display: block;
text-align: center;
}
#arrow {
margin-top: 10px;
border: solid #FFF;
border-width: 0 3px 3px 0;
display: block;
padding: 3px;
transform: rotate(45deg);
-webkit-transform: rotate(45deg);
width: 5px;
height: 5px;
}
<section id="blue">
<div id="box2">
<span id="box2Text">View Services</span>
<div id="arrow"></div>
</div>
</section>

Like this?
#blue {
width: 100%;
height: 100vh;
background: blue;
}
#box2 {
position: absolute;
top: 25%;
right: 25%;
z-index: 1;
}
#box2Text {
color: #FFF;
font-family: 'Muli', sans-serif;
font-size: 2rem;
font-weight: 300;
line-height: 1.4em;
padding: 80px;
border: 6px solid #FFF;
border-radius: 2px;
display: block;
text-align: center;
}
#arrow {
margin-right:15px;
margin-bottom:5px;
border: solid #FFF;
border-width: 0 3px 3px 0;
display: inline-block;
padding: 3px;
transform: rotate(-45deg);
-webkit-transform: rotate(-45deg);
width: 5px;
height: 5px;
}
<section id="blue">
<div id="box2">
<span id="box2Text"><div id="arrow"></div><span>View Services</span></span>
</div>
</section>

Related

Images destroy the card format

I have a grid layout of cards. When I upload photos to a product card, there are several times that the entire format of the card is damaged. That is, no labels, the name, the description of the product and some other things are not visible.
I am attaching 2 screenshots (one without and one with photos)
.bg-color {
background-color: #eee;
padding: 60px 0;
}
.containers {
width: 90%;
margin: 0 auto;
}
.title {
margin-bottom: 50px;
padding-bottom: 40px;
text-align: center;
position: relative;
}
.title::before {
content: '';
width: 200px;
height: 3px;
background-color: #dbdbdb;
position: absolute;
bottom: 15%;
left: 50%;
transform: translateX(-50%);
}
.title::after {
content: '\f005';
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
color: #dbdbdb;
width: 50px;
height: 20px;
text-align: center;
line-height: 20px;
position: absolute;
bottom: 10%;
left: 10%;
/* background-color: #eee;
*/
transform: translateX(-50%);
font-size: 16px;
}
.title p {
color: #999;
font-style: italic;
font-weight: 700;
margin: 0;
}
.title h1 {
font-size: 44px;
color: #131313;
font-weight: 900;
text-transform: capitalize;
}
.title h1 span {
color: #fa0;
}
.my-card {
transition: all .2s ease-in-out;
border-radius: 3px;
}
.card-main {
position: relative;
}
.price {
position: absolute;
background: #fa0;
font-weight: 700;
color: #ffff;
text-align: center;
display: block;
text-transform: uppercase;
height: 30px;
width: 50px;
border-radius: 0 15px 15px 0;
line-height: 30px;
font-style: italic;
left: -9px;
top: 30px;
}
.price::after {
border-top: 6px solid #c80;
content: '';
position: absolute;
bottom: -6px;
left: 0;
border-left: 8px solid transparent;
border-right: 0px solid transparent;
}
.label {
position: absolute;
top: 10px;
/* bottom: 104px;
*/
left: -9px;
font-size: 10px;
font-weight: 400;
text-transform: uppercase;
z-index: 2;
line-height: 100%;
color: #ffff;
border-radius: 3px;
padding: 5px 8px;
}
.label-green {
background: #5cb85c;
}
.label2 {
position: absolute;
top: 10px;
/* bottom: 104px;
*/
right: -9px;
font-size: 10px;
font-weight: 400;
text-transform: uppercase;
z-index: 2;
line-height: 100%;
color: #ffff;
border-radius: 3px;
padding: 5px 8px;
}
.label-red {
background: #C5312D;
}
.image img {
width: 100%;
height: 100%;
position: center;
}
.cart-line {
height: 2px;
background: #f1f1f1;
}
.cart-item {
text-align: center;
line-height: 45px;
background: #fa0;
/* background: rgb(199, 136, 53);
*/
transition: all 0.4s ease-in-out;
position: relative;
top: -30px;
}
.cart-item ul {
padding: 0;
margin: 0;
}
.cart-item ul li {
display: inline-block;
list-style-type: none;
position: relative;
font-size: 25px;
}
.cart-item ul li::after {
content: '';
width: 1px;
height: 18px;
background: rgba(255, 255, 255, .15);
position: absolute;
left: -2px;
top: 10px;
}
.my-card:hover .cart-item {
opacity: 1;
top: 0;
}
.item-container {
position: absolute;
right: -40px;
top: 10px;
z-index: 4;
transition: 0.6s;
opacity: 0;
}
.p {
border: 1px solid rgb(233, 233, 233);
border-radius: 2px;
height: 40px;
width: 40px;
cursor: pointer;
}
.p img {
width: 100%;
height: 100%;
opacity: 0.8;
}
.p img:hover {
opacity: 1;
}
.my-card:hover .item-container {
opacity: 1;
right: 10px;
}
.content {
padding: 16px 0;
text-align: center;
}
.content mat-card-title {
font-size: 16px;
color: #555;
font-weight: 700;
text-transform: capitalize;
transition: all .3s;
}
.content mat-card-title:hover {
color: #fa0;
text-decoration: none;
}
.content p {
margin-bottom: 0;
}
.content .description {
font-size: 15px;
color: #fa0;
font-weight: 500;
font-style: italic;
margin-right: 6px;
}
<section class="bg-color">
<div class="containers">
<mat-grid-list [cols]="breakpoint" rowHeight="500px" (window:resize)="onResize($event)">
<mat-grid-tile *ngFor="let item of pagedList">
<div>
<mat-card class="my-card">
<div class="card-main">
<div *ngIf="item.buy_price != 0">
<div class="label label-green">Buy NOW</div>
<div class="price">{{item.buy_price | currency:'EUR':true}}</div>
</div>
<div *ngIf="item.seller == username">
<div class="label2 label-red">My item</div>
</div>
<!-- Small images -->
<div class="item-container">
<div *ngIf="item.images.length!==0">
<div *ngFor="let image of item.images">
<div class="p"><img [src]="'data:image/jpeg;base64,' + image.imageByte" alt="item"> </div>
</div>
</div>
</div>
<!-- 1st image -->
<div class="image">
<div *ngIf="item.images.length==0">
<img src="/assets/images/no_image_found.jpg" alt="image">
</div>
<div *ngIf="item.images.length!=0">
<img [src]="'data:image/jpeg;base64,' + item.images[0].imageByte" alt="image">
</div>
</div>
<div class="cart-line"></div>
<div class="cart-item">
<ul>
<li><a routerLink="/item-detail/{{item.id}}"><i class="bi-basket"></i></a></li>
</ul>
</div>
</div>
<div class="content">
<mat-card-title>{{item.name.length>34?item.name.substring(0,30)+ "...":item.name}}</mat-card-title>
<p><span class="description">{{item.description.length>34?item.description.substring(0,30)+ "...":item.description}}</span></p>
</div>
</mat-card>
</div>
</mat-grid-tile>
</mat-grid-list>
</div>
</section>

HTML CSS Button

I want to create the following button until tomorrow
I managed to create this with only css and html
and here is my code.
.date {
color: #7ed2f6;
font-size: 40px;
font-weight: bold;
}
.save {
color: white;
font-size: 40px;
font-weight: bold;
}
.pill-button {
border: 0.2em solid white;
color: white;
padding: 10px 20px;
text-align: center;
display: inline-block;
margin: 4px 2px;
cursor: pointer;
border-radius: 60px;
}
.right {
display: inline-block;
width: 4em;
height: 4em;
border: 0.3em solid white;
border-radius: 50%;
margin-left: 1.5em;
}
.right:after {
content: '';
display: inline-block;
margin-top: 1.05em;
margin-left: -0.6em;
width: 1.2em;
height: 1.2em;
border-top: 0.3em solid white;
border-right: 0.3em solid white;
-moz-transform: rotate(45deg);
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
.greyline {
border-left: 2px solid #8d9ab1;
height: 81px;
display: inline-block;
}
<a href="#" class="pill-button">
<span class="save">Save The Date</span>
<div class="greyline"></div>
<span class="date">Σάββατο 19/9/2020 16:30-17:30</span>
<span class="right"></span>
</a>
I cant make it work with the line change
I know this snippet doesn't have the same dimensions as yours but I think it should help you out.
body {
background-image: linear-gradient(to right, #1b2e52, #243f73);
margin: 3em;
}
.pill-button {
background-color: transparent;
font-size: 1em;
border: 0.125em solid white;
color: white;
margin: 1em 0;
padding: 0.625em 4.375em 0.625em 1.25em;
display: inline-flex;
align-items: center;
cursor: pointer;
border-radius: 3.75em;
text-decoration: none;
font-family: sans-serif;
position: relative;
width: 33.125em;
box-sizing: border-box;
}
.pill-button::before {
content: "";
width: 2.5em;
height: 2.5em;
border: 0.125em solid white;
border-radius: 50%;
position: absolute;
right: 0.375em;
top: 50%;
transform: translateY(-50%);
}
.pill-button::after {
content: "";
display: inline-block;
width: 0.625em;
height: 0.625em;
border-top: 0.1875em solid white;
border-right: 0.1875em solid white;
position: absolute;
right: 1.5em;
top: 50%;
transform: translateY(-50%) rotate(45deg);
}
.pill-button__save {
color: white;
font-size: 1.875em;
font-weight: bold;
padding-right: 0.5em;
margin-right: 0.5em;
position: relative;
min-width: 7em;
}
.pill-button__save::after {
content: "";
position: absolute;
right: 0;
top: 50%;
transform: translateY(-50%);
width: 0.0333333333em;
height: 1.1666666667em;
background-color: #8d9ab1;
}
.pill-button__date {
color: #7ed2f6;
font-size: 1.25em;
font-weight: bold;
text-align: center;
}
.pill-button__time-range {
display: block;
}
<a href="#" class="pill-button">
<span class="pill-button__save">Save The Date</span>
<span class="pill-button__date">Σάββατο 19/9/2020 <span class="pill-button__time-range">16:30-17:30</span></span>
</a>
<button class="pill-button">
<span class="pill-button__save">Save The Date</span>
<span class="pill-button__date">Σάββατο 19/9/2020 <span class="pill-button__time-range">16:30-17:30</span></span>
</button>
The main idea to do this with flex. I did small refactoring.
.date{
color:#7ed2f6;
font-size:40px;
font-weight: bold;
}
.save{
color:white;
font-size:40px;
font-weight: bold;
}
.pill-button {
background-color: blue;
border: 0.2em solid white;
color: white;
padding: 10px 20px;
text-align: center;
/* Added */
display: flex;
align-items: center;
justify-content: space-between;
/* End Added */
margin: 4px 2px;
cursor: pointer;
border-radius: 60px;
}
.right {
/* display: inline-block; */
width: 4em;
height: 4em;
border: 0.3em solid white;
border-radius: 50%;
margin-left: 1.5em;
}
.right:after {
content: '';
display: inline-block;
margin-top: 1.05em;
margin-left: -0.6em;
width: 1.2em;
height: 1.2em;
border-top: 0.3em solid white;
border-right: 0.3em solid white;
-moz-transform: rotate(45deg);
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
.greyline {
border-left: 2px solid #8d9ab1;
height: 81px;
/* display: inline-block; */
}
<a href="#" class="pill-button">
<span class="save">Save The Date</span>
<div class="greyline"></div>
<span class="date">Σάββατο 19/9/2020 16:30-17:30</span>
<span class="right"></span>
</a>
.date{
color:#7ed2f6;
font-size:40px;
font-weight: bold;
display: inline-block;
padding-left:15px;
margin-left:15px;
border-left: 2px solid #8d9ab1;
line-height:1;
}
.save{
color:white;
font-size:20px;
font-weight: bold;
vertical-align:middle;
}
.pill-button {
border: 0.2em solid white;
color: white;
padding: 10px 10px;
text-align: center;
display: flex;
width: max-content;
margin: 4px 2px;
cursor: pointer;
border-radius: 50px;
align-items: center;
background-color:#152b47;
}
.right {
display: inline-block;
width: 4em;
height: 4em;
border: 0.3em solid white;
border-radius: 50%;
margin-left: 1.5em;
}
.right:after {
content: '';
display: inline-block;
margin-top: 1.05em;
margin-left: -0.6em;
width: 1.2em;
height: 1.2em;
border-top: 0.3em solid white;
border-right: 0.3em solid white;
-moz-transform: rotate(45deg);
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
.greyline {
border-left: 2px solid #8d9ab1;
height: 81px;
display: inline-block;
}
<div class="pill-button">
<span class="save">Save The Date</span>
<div class="date">
Σάββατο 19/9/2020<br>
16:30-17:30
</div>
<span class="right"></span>
</div>

Several images with title

I have a background with an image, in this bakground I have 3 images with 3 numbers. I would like for each number, center the number with the image.
I am stuck with the property margin-left
.background-picture-red{
height: 130px;
width: 100%;
position: absolute;
background-image: url(https://i.ibb.co/jVWdfG4/bg-2.jpg);
}
.picture01{
border: 1px solid #fff;
padding: 10px;
border-radius: 50%;
background-color: rgba(224,0,0,0.30);
float:left;
margin-top: 10px;
margin-left: 50px;
z-index: 1;
position: relative;
}
.picture01-title{
font-family: 'Questrial', sans-serif;
font-size: 16px;
color: white;
margin-left: 50px;
margin-top: 100px;
position: absolute;
}
.picture02{
border: 1px solid #fff;
padding: 10px;
border-radius: 50%;
background-color: rgba(224,0,0,0.30);
float:left;
margin-top: 10px;
margin-left: 60px;
z-index: 1;
position: relative;
}
.picture02-title{
font-family: 'Questrial', sans-serif;
font-size: 16px;
color: white;
margin-left: 50px;
margin-top: 100px;
position: absolute;
}
.picture03{
border: 1px solid #fff;
padding: 10px;
border-radius: 50%;
background-color: rgba(224,0,0,0.30);
float:left;
margin-top: 10px;
margin-left: 70px;
z-index: 1;
position: relative;
}
.picture03-title{
font-family: 'Questrial', sans-serif;
font-size: 16px;
color: white;
margin-left: 10px;
margin-top: 100px;
position: absolute;
}
<div class="background-picture-red">
<img class="picture01" src="https://i.ibb.co/n3fv0YY/bitcoin34.png">
<span class="picture01-title">138</span>
<img class="picture02" src="https://i.ibb.co/qRSr1Wr/bitcoin46.png">
<span class="picture02-title">258</span>
<img class="picture03" src="https://i.ibb.co/BwT7gHz/bitcoin68.png">
<span class="picture03-title">303</span>
</div>
Here is a working example where I added to each title:
margin-left: -43px;
transform:translateX(-50%);
margin-left: -43px : because your image size is 86px so -43px will be placed in the middle of the image
translateX(-50%) : so the text will be centered depending of its own size
.background-picture-red{
height: 130px;
width: 100%;
position: absolute;
background-image: url(https://i.ibb.co/jVWdfG4/bg-2.jpg);
}
.picture01{
border: 1px solid #fff;
padding: 10px;
border-radius: 50%;
background-color: rgba(224,0,0,0.30);
float:left;
margin-top: 10px;
margin-left: 50px;
z-index: 1;
position: relative;
}
.picture01-title{
font-family: 'Questrial', sans-serif;
font-size: 16px;
color: white;
margin-left: -43px;
transform:translateX(-50%);
margin-top: 100px;
position: absolute;
}
.picture02{
border: 1px solid #fff;
padding: 10px;
border-radius: 50%;
background-color: rgba(224,0,0,0.30);
float:left;
margin-top: 10px;
margin-left: 60px;
z-index: 1;
position: relative;
}
.picture02-title{
font-family: 'Questrial', sans-serif;
font-size: 16px;
color: white;
margin-left: -43px;
transform:translateX(-50%);
margin-top: 100px;
position: absolute;
}
.picture03{
border: 1px solid #fff;
padding: 10px;
border-radius: 50%;
background-color: rgba(224,0,0,0.30);
float:left;
margin-top: 10px;
margin-left: 70px;
z-index: 1;
position: relative;
}
.picture03-title{
font-family: 'Questrial', sans-serif;
font-size: 16px;
color: white;
margin-left: -43px;
transform:translateX(-50%);
margin-top: 100px;
position: absolute;
}
<div class="background-picture-red">
<img class="picture01" src="https://i.ibb.co/n3fv0YY/bitcoin34.png">
<span class="picture01-title">138</span>
<img class="picture02" src="https://i.ibb.co/qRSr1Wr/bitcoin46.png">
<span class="picture02-title">258</span>
<img class="picture03" src="https://i.ibb.co/BwT7gHz/bitcoin68.png">
<span class="picture03-title">303</span>
</div>
But maybe you should use flexbox to do that kind of thing.

How do I get this button layout?

I'm trying to get this layout.
<blockquote class="imgur-embed-pub" lang="en" data-id="a/kCjW9"></blockquote><script async src="//s.imgur.com/min/embed.js" charset="utf-8"></script>
Here's the code I have. I can't seem to get z-index to work so that I could bring black border on top of the background.
<blockquote class="imgur-embed-pub" lang="en" data-id="a/6a7Ev"></blockquote><script async src="//s.imgur.com/min/embed.js" charset="utf-8"></script>
.btn {
border-radius: 0px!important;
font-family: $font-roboto!important;
font-size: 1.125rem!important;
text-shadow: none!important;
box-shadow: none!important;
&.fountain-blue {
background-color: $color-fountain-blue;
color: #fff;
margin-left:5px;
margin-top: 5px;
margin-right: -10px;
}
}
.btn-border {
border: 2px solid #000;
display: inline-block;
height: 40px;
z-index: 9999!important;
}
<div class="btn-border mt-4">
learn more about us
</div>
There are a lot of ways to do this but simple method is to use pseudo-elements. check out the snippet.
CODEPEN (SASS version)
#import url("https://fonts.googleapis.com/css?family=Roboto");
.btn {
border-radius: 0px;
font-size: 1.125rem;
text-shadow: none;
box-shadow: none;
display: block;
width: calc(100% - 25px);
text-decoration: none;
font-family: 'Roboto', sans-serif;
text-align: center;
}
.btn.fountain-blue {
background-color: #65becf;
color: #fff;
margin-left: 5px;
margin-top: 5px;
padding-top: 10px;
padding-bottom: 15px;
padding-left: 15px;
padding-right: 15px;
position: relative;
}
.btn-border {
display: inline-block;
height: 40px;
z-index: 9999;
position: absolute;
left: 50%;
top: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.btn-border:after {
content: '';
border: 2px solid #000;
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
}
<div class="btn-border mt-4">
READ MORE
</div>
You should do it something like this, but than with your own colors and sizes.
.btn {
display: inline-block;
border: 1px solid black;
position: relative;
padding: 10px 20px;
margin: 20px;
color: #fff;
}
.btn:before {
background-color: blue;
border-color: green;
border-style: solid;
border-width: 10px 5px 5px 10px;
z-index: -1;
position: absolute;
height: 100%;
width: 100%;
top: -5px;
left: -5px;
content: "";
}
<a class="btn">Read more</a>
As a possible solution.
* {
box-sizing: border-box;
}
body {
margin: 2em;
}
.btn {
background-color: darkblue;
color: white;
border: .2em solid white;
height: 2.5em;
width: 7em;
position: relative;
cursor: pointer;
}
.btn:before {
content: " ";
width: 9em;
height: 4em;
background-color: lightblue;
position: absolute;
top: -1em;
left: -1em;
z-index: -1;
}
.btn:after {
content: " ";
position: absolute;
background-color: transparent;
border: thin solid black;
height: 2em;
width: 6.5em;
top: -.5em;
left: -.5em;
}
<button class="btn">Click me</button>

Replicating nutrition label - expert CSS level

I am trying to emulate this nutrition label format in CSS, but I can't get the shapes right at all. The best I can come up with is fiddling with border-radius, but that gives me more of a pill shape, and still not way to get the black cut-out shape at the bottom. Has anyone replicated such a nutrition label in CSS? Would anyone be willing to try? Any help would be greatly appreciated.
Here is a link to what I have so far: jsfiddle.net/f5jczunf/
#block {
border-radius:50%/10px;
background: #ccc;
padding: 20px;
width: 50px;
height: 100px;
border: 1px solid #000;
background-color:#FFF;
text-align:center;
}
.number {
font-weight:bold;
font-size:18pt;
text-align:center;
}
<div id="block">
<span class="number">150</span>
<br/>Calories
</div>
Maybe this small example can help.
.label {
position: relative;
width: 100px;
height: 140px;
text-align: center;
border: 1px solid #000;
border-radius: 100px/50px;
overflow: hidden;
}
.title {
display: inline-block;
margin-top: 30px;
}
.bottom {
position: absolute;
bottom: -10px;
left: 0;
right: 0;
height: 50px;
color: #fff;
line-height: 40px;
border-top: 1px solid #000;
border-radius: 100px/50px;
background-color: #000;
}
<div class="label">
<span class="title">Title</span>
<span class="bottom">Bottom</span>
</div>
https://jsfiddle.net/9xs2wcbL/1/
Here's my take on it. It does require some advanced, bleeding edge CSS, however.
#import url('https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300');
body {
padding: 3em;
font-size: 16px;
font-family: 'Open Sans Condensed', sans-serif;
}
.label-list {
display: -webkit-inline-box;
display: -ms-inline-flexbox;
display: inline-flex;
}
.label-list .label-item {
text-align: center;
border: 1px solid;
position: relative;
border-radius: 2em / 0.65em;
padding: 0.2em 0.25em 1.5em;
min-width: 3.5em;
overflow: hidden;
margin: 0.1em;
z-index: 1;
background: white;
color: black;
}
.label-list .label-item h1 {
font-size: 3em;
line-height: 1em;
font-weight: 900;
margin: 0;
}
.label-list .label-item h1.smaller {
font-size: 1.75em;
margin-top: 0.5em;
}
.label-list .label-item h1 small {
font-size: 0.4em;
text-transform: none;
}
.label-list .label-item small {
font-size: 1em;
line-height: 1em;
font-weight: 900;
text-transform: uppercase;
}
.label-list .label-item span {
position: absolute;
bottom: 0.5em;
left: 0;
right: 0;
color: white;
font-size: 0.8em;
line-height: 1em;
}
.label-list .label-item span:before {
content: '';
position: absolute;
bottom: 0;
left: 0;
right: 0;
top: 0;
background: black;
z-index: -1;
border-radius: 40%;
transform-origin: center;
width: 100%;
height: 0;
padding-top: 100%;
margin: auto;
transform: rotate(45deg) translate(20%, 20%);
}
<div class="label-list">
<div class="label-item">
<h1>140</h1>
<small>Calories</small>
</div>
<div class="label-item">
<h1 class="smaller">1<small>g</small></h1>
<small>Sat Fat</small>
<span>5% DV</span>
</div>
</div>
I believe the only way to have this sort of shape in pure CSS is with a few overlapping shapes, something similar to the code below:
.wrapper {
position: relative;
height: 112px;
width: 80px;
overflow: hidden;
}
.rectangle,
.circle {
position: absolute;
box-sizing: border-box;
}
.rectangle {
height: 96px;
width: 80px;
top: 8px;
border-left: 1px solid black;
border-right: 1px solid black;
}
.circle {
width: 200px;
height: 200px;
left: -60px;
border-radius: 200px;
border: 1px solid black;
}
.top {
top: 0;
}
.bottom {
bottom: 0;
}
<div class="wrapper">
<div class="circle top"></div>
<div class="rectangle"></div>
<div class="circle bottom"></div>
</div>
https://jsfiddle.net/dylanstark/01hck5dv/
here my approach for that. I'm using before and after pseudo-elements.
before contains black bg with border-radius and it is overflowing the main #block which has overflow: hidden;.
aftercontains text that is coming from data-text attribute of #block
#block {
border-radius: 50%/10px;
background: #ccc;
padding: 20px;
width: 50px;
height: 100px;
border: 1px solid #000;
background-color: #FFF;
text-align: center;
position: relative;
overflow: hidden;
}
#block:before {
display: block;
content: " ";
position: absolute;
bottom: -15px;
left: 0;
width: 100%;
height: 50px;
border-radius: 50%;
background: black;
z-index: 0;
}
#block:after {
display: block;
content: attr(data-label);
position: absolute;
bottom: 5px;
color: white;
text-align: center;
z-index: 1;
}
.number {
font-weight: bold;
font-size: 18pt;
text-align: center;
}
<div id="block" data-label="5% DY">
<span class="number">150</span>
<br/>Calories
</div>