CSS Grid: collapse width of just 1 column - html

I have a grid with 3 columns: I need the first 1 column to always take the smallest amount of space possible, so the second column is tight with the text. I also need to cover a situation where the text of the first column can be huge:
Here I want the CSS to be exactly as is, since it's perfect. The CSS is really simple:
.container {
display: grid;
}
.children {
grid-row: 1;
}
How can I achieve the desired result with css grid?
Codepen link for minimal case: https://codepen.io/ilia-reingold/pen/RwrdELR
Update: adding code ->
.margin-top {
margin-top: 1rem;
}
.row {
display: flex;
flex-direction: row;
flex: 1;
align-items: center;
}
.title-container {
display: grid;
// grid-template-columns: auto 10% 10%;
}
.title {
grid-row: 1;
font-family: Poppins;
font-style: normal;
font-weight: 600;
font-size: 24px;
line-height: 36px;
color: #000000;
}
.container {
grid-row: 1;
}
.buttons {
grid-row: 1;
}
.description {
font-family: Rubik;
font-style: normal;
font-weight: normal;
font-size: 16px;
line-height: 19px;
color: #404A56;
}
.end {
justify-content: flex-end;
}
.container {
display: flex;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
-ms-flex-direction: row;
flex-direction: row;
margin: 0 0.5rem;
align-items: center;
}
<div data-v-31045a46="" class="pagetop row margin-top">
<div data-v-31045a46="" class="title-container row">
<div data-v-31045a46="" class="text-ellipsis title"> Hardik's Favourite </div>
<div data-v-52c45aaf="" data-v-31045a46="" class="container">
<div data-v-52c45aaf="" class="status-button read-only">
<svg data-v-52c45aaf="" width="16" height="22" viewBox="0 0 16 22" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M13 7.5H14C15.1 7.5 16 8.4 16 9.5V19.5C16 20.6 15.1 21.5 14 21.5H2C0.9 21.5 0 20.6 0 19.5V9.5C0 8.4 0.9 7.5 2 7.5H3V5.5C3 2.74 5.24 0.5 8 0.5C10.76 0.5 13 2.74 13 5.5V7.5ZM8 2.5C6.34 2.5 5 3.84 5 5.5V7.5H11V5.5C11 3.84 9.66 2.5 8 2.5ZM2 19.5V9.5H14V19.5H2ZM10 14.5C10 15.6 9.1 16.5 8 16.5C6.9 16.5 6 15.6 6 14.5C6 13.4 6.9 12.5 8 12.5C9.1 12.5 10 13.4 10 14.5Z" fill="black" fill-opacity="0.54"></path>
</svg>
<span data-v-52c45aaf="">Read-only</span>
</div>
<div data-v-52c45aaf="" class="status-button shared pointer">
<svg data-v-52c45aaf="" width="20" height="14" viewBox="0 0 20 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M7 7C8.93 7 10.5 5.43 10.5 3.5C10.5 1.57 8.93 0 7 0C5.07 0 3.5 1.57 3.5 3.5C3.5 5.43 5.07 7 7 7ZM0 12.25C0 9.92 4.66 8.75 7 8.75C9.34 8.75 14 9.92 14 12.25V14H0V12.25ZM7 10.75C5.21 10.75 3.18 11.42 2.34 12H11.66C10.82 11.42 8.79 10.75 7 10.75ZM8.5 3.5C8.5 2.67 7.83 2 7 2C6.17 2 5.5 2.67 5.5 3.5C5.5 4.33 6.17 5 7 5C7.83 5 8.5 4.33 8.5 3.5ZM14.04 8.81C15.2 9.65 16 10.77 16 12.25V14H20V12.25C20 10.23 16.5 9.08 14.04 8.81ZM16.5 3.5C16.5 5.43 14.93 7 13 7C12.46 7 11.96 6.87 11.5 6.65C12.13 5.76 12.5 4.67 12.5 3.5C12.5 2.33 12.13 1.24 11.5 0.35C11.96 0.13 12.46 0 13 0C14.93 0 16.5 1.57 16.5 3.5Z" fill="#6E6F73"></path>
</svg>
<span data-v-52c45aaf="">Shared with team</span>
</div>
</div>
<div data-v-31045a46="" class="buttons row end">
<button data-v-5ea9ad22="" data-v-31045a46="" data-testid="button" class="button">
<div data-v-5ea9ad22="" class="centered">
<svg data-v-31045a46="" width="22" height="22" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg" data-v-5ea9ad22="">
<rect x="7" y="7" width="14" height="14" rx="2" stroke="black" stroke-width="2"></rect>
<path fill-rule="evenodd" clip-rule="evenodd" d="M3 2H13C13.5523 2 14 2.44772 14 3V6H16V3C16 1.34315 14.6569 0 13 0H3C1.34315 0 0 1.34315 0 3V13C0 14.6569 1.34315 16 3 16H6V14H3C2.44772 14 2 13.5523 2 13V3C2 2.44772 2.44772 2 3 2Z" fill="black"></path>
</svg>
<span data-v-5ea9ad22=""> Copy </span>
</div>
</button>
<button data-v-5ea9ad22="" data-v-31045a46="" data-testid="button" class="disabled button">
<div data-v-5ea9ad22="" class="centered">
<svg data-v-31045a46="" width="14" height="12" viewBox="0 0 14 12" fill="none" xmlns="http://www.w3.org/2000/svg" data-v-5ea9ad22="">
<path d="M13.7728 4.22774L8.96019 0.15672C8.53894 -0.199663 7.875 0.0896491 7.875 0.643255V2.78753C3.4828 2.83679 0 3.6991 0 7.77658C0 9.42231 1.08229 11.0527 2.27864 11.9051C2.65196 12.1711 3.18402 11.8373 3.04637 11.4061C1.80649 7.52179 3.63445 6.4906 7.875 6.43084V8.7857C7.875 9.34016 8.53946 9.62819 8.96019 9.27223L13.7728 5.20081C14.0755 4.94469 14.0759 4.48421 13.7728 4.22774Z" fill="#8d8f93"></path>
</svg>
<span data-v-5ea9ad22=""> Share </span>
</div>
</button>
<div data-v-31045a46="" role="listbox" tabindex="0" class="ui dropdown dropdown icon disabled-grey-btn" compact="compact">
<i aria-hidden="true" class="ellipsis horizontal icon"></i><span class="sizer"></span>
<div tabindex="-1" class="menu transition"></div>
</div>
</div>
</div>
</div>

You can achieve that by using grid-template-columns property.
.container {
display: grid;
grid-template-columns:20% 40% 40%; //It's just a hit, try on your own
}

You can add this to your CSS
.text-ellipsis {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
Result:

Related

How can I stack my hyperlink images on top of each other in HTML/CSS [duplicate]

This question already has answers here:
How to make an inline element appear on new line, or block element not occupy the whole line?
(9 answers)
Links on New Line
(10 answers)
How to line-break 2 anchors
(3 answers)
Move <a> tag to a new line without <br>
(5 answers)
Closed 1 year ago.
It's my first time creating a website and I want to add these images as hyperlinks stacked on top of each other. However, they're stacked horizontally even though I was following a tutorial.
This is my HTML code:
.socials {
padding-bottom: 200px;
padding-right: 16px;
}
.social {
margin: 10px;
}
<div class="socials">
<a href="http://www.linkedin.com" class="social">
<svg xmlns="http://www.w3.org/2000/svg" fill="#ffffff" width="50" height="50" viewBox="0 0 24 24"><path d="M4.98 3.5c0 1.381-1.11 2.5-2.48 2.5s-2.48-1.119-2.48-2.5c0-1.38 1.11-2.5 2.48-2.5s2.48 1.12 2.48 2.5zm.02 4.5h-5v16h5v-16zm7.982 0h-4.968v16h4.969v-8.399c0-4.67 6.029-5.052 6.029 0v8.399h4.988v-10.131c0-7.88-8.922-7.593-11.018-3.714v-2.155z"/></svg> </a>
</a>
<a href="http://www.github.com" class="social">
<svg xmlns="http://www.w3.org/2000/svg" fill="#ffffff" width="50" height="50" viewBox="0 0 24 24"><path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"/></svg>
</a>
<a href="http://www.instagram.com" class="social">
<svg xmlns="http://www.w3.org/2000/svg" fill="#ffffff" width="50" height="50" viewBox="0 0 24 24"><path d="M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zm0-2.163c-3.259 0-3.667.014-4.947.072-4.358.2-6.78 2.618-6.98 6.98-.059 1.281-.073 1.689-.073 4.948 0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98 1.281.058 1.689.072 4.948.072 3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98-1.281-.059-1.69-.073-4.949-.073zm0 5.838c-3.403 0-6.162 2.759-6.162 6.162s2.759 6.163 6.162 6.163 6.162-2.759 6.162-6.163c0-3.403-2.759-6.162-6.162-6.162zm0 10.162c-2.209 0-4-1.79-4-4 0-2.209 1.791-4 4-4s4 1.791 4 4c0 2.21-1.791 4-4 4zm6.406-11.845c-.796 0-1.441.645-1.441 1.44s.645 1.44 1.441 1.44c.795 0 1.439-.645 1.439-1.44s-.644-1.44-1.439-1.44z"/></svg>
</a>
</div>
To demonstrate, I replaced your SVG's with Images. You can use flex-box with flex-direction: column; to have your images stack. Also, for good measures, I positioned it in the center. See below.
.socials {
display: flex;
flex-direction: column;
align-items: center;
}
<div class="socials">
<a href="http://www.linkedin.com" class="social">
<img src="https://dummyimage.com/50/000/fff">
</a>
<a href="http://www.github.com" class="social">
<img src="https://dummyimage.com/50/000/fff">
</a>
<a href="http://www.instagram.com" class="social">
<img src="https://dummyimage.com/50/000/fff">
</a>
</div>
with CSS GRID
css grid automatically puts everything in row mode :)
...few lines and your work is complete!
-or with flex-box it automatically transforms everything into columns, so you need to write an extra CSS property flex-direction
so go for display: grid; I think is the best, simplest solution :)
.socials {
display: grid;
gap: 1rem;
}
.social svg {
fill: blue;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="socials">
<a href="http://www.linkedin.com" class="social">
<svg xmlns="http://www.w3.org/2000/svg" fill="#ffffff" width="50" height="50" viewBox="0 0 24 24"><path d="M4.98 3.5c0 1.381-1.11 2.5-2.48 2.5s-2.48-1.119-2.48-2.5c0-1.38 1.11-2.5 2.48-2.5s2.48 1.12 2.48 2.5zm.02 4.5h-5v16h5v-16zm7.982 0h-4.968v16h4.969v-8.399c0-4.67 6.029-5.052 6.029 0v8.399h4.988v-10.131c0-7.88-8.922-7.593-11.018-3.714v-2.155z"/></svg>
</a>
<a href="http://www.github.com" class="social">
<svg xmlns="http://www.w3.org/2000/svg" fill="#ffffff" width="50" height="50" viewBox="0 0 24 24"><path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"/></svg>
</a>
<a href="http://www.instagram.com" class="social">
<svg xmlns="http://www.w3.org/2000/svg" fill="#ffffff" width="50" height="50" viewBox="0 0 24 24"><path d="M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zm0-2.163c-3.259 0-3.667.014-4.947.072-4.358.2-6.78 2.618-6.98 6.98-.059 1.281-.073 1.689-.073 4.948 0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98 1.281.058 1.689.072 4.948.072 3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98-1.281-.059-1.69-.073-4.949-.073zm0 5.838c-3.403 0-6.162 2.759-6.162 6.162s2.759 6.163 6.162 6.163 6.162-2.759 6.162-6.163c0-3.403-2.759-6.162-6.162-6.162zm0 10.162c-2.209 0-4-1.79-4-4 0-2.209 1.791-4 4-4s4 1.791 4 4c0 2.21-1.791 4-4 4zm6.406-11.845c-.796 0-1.441.645-1.441 1.44s.645 1.44 1.441 1.44c.795 0 1.439-.645 1.439-1.44s-.644-1.44-1.439-1.44z"/></svg>
</a>
</div>
</body>
</html>
if you want to learn more about grid: https://www.freecodecamp.org/learn/responsive-web-design/css-grid/create-your-first-css-grid
this really help me a lot to understand it

How do I center the dots (SVG) with the class .stroke1

This is the needed code
.strokes {
display: flex;
width: 100%;
}
.stroke1 {
position: absolute;
z-index: 1002;
justify-content: center;
text-align: center;
align-items: center;
}
<section class="home" id="home">
<div class="max-width">
<div class="star star1"></div>
<div class="home-content">
<div class="text-1">Hello, my name is</div>
<div class="text-2">Hadi Zouhbi</div>
<div class="text-3">And I'm a <span class="txt-rotate"
data-period="2000"
data-rotate='[ "Developer.", "UX Designer.", " Programmer.", "Full-Stack Dev.", "Marketer" ]'
id="headSpan"></span></div>
Hire Me
</div>
</div>
</section>
</header>
<div class="strokes">
<svg class="stroke1" stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 1024 1024" height="3em" width="3em" xmlns="http://www.w3.org/2000/svg"><path d="M456 231a56 56 0 1 0 112 0 56 56 0 1 0-112 0zm0 280a56 56 0 1 0 112 0 56 56 0 1 0-112 0zm0 280a56 56 0 1 0 112 0 56 56 0 1 0-112 0z"></path></svg>
</div>
I want the stroke to be in the middle of the page but nothing is working , it always stays on the left side , am I doing anything wrong ?
If all you're trying to do is center the <svg> then there were a couple issues with your code. First, justify-content and align-items need to be set on the flex container itself (i.e. the same element that has the display: flex rule applied to it), not its children. Second, anything that is absolutely positioned will override any inherent flex positioning applied to it, so I don't think you want that in this case.
Here's an updated code snippet that addresses the above points and thus centers the dots.
.strokes {
display: flex;
justify-content: center;
text-align: center;
align-items: center;
width: 100%;
}
.stroke1 {
z-index: 1002;
}
<section class="home" id="home">
<div class="max-width">
<div class="star star1"></div>
<div class="home-content">
<div class="text-1">Hello, my name is</div>
<div class="text-2">Hadi Zouhbi</div>
<div class="text-3">And I'm a <span class="txt-rotate"
data-period="2000"
data-rotate='[ "Developer.", "UX Designer.", " Programmer.", "Full-Stack Dev.", "Marketer" ]'
id="headSpan"></span></div>
Hire Me
</div>
</div>
</section>
</header>
<div class="strokes">
<svg class="stroke1" stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 1024 1024" height="3em" width="3em" xmlns="http://www.w3.org/2000/svg"><path d="M456 231a56 56 0 1 0 112 0 56 56 0 1 0-112 0zm0 280a56 56 0 1 0 112 0 56 56 0 1 0-112 0zm0 280a56 56 0 1 0 112 0 56 56 0 1 0-112 0z"></path></svg>
</div>

On scroll transform the element from bottom to center of the screen and remains center until the section's bottom touch the viewport's bottom

I want to animate a element on scroll which is already tranlateY to 400% using CSS, now when the user scroll to that section it will come's up on 10% of scroll and when it's reached to the center of page it remains center until the section has completed scrolled.
In this fiddle you can see the svg image code but it's not working properly i want both circle and svg animation at the same time i have commented the fiddle url
$(window).scroll(function() {
inViewport();
});
$(window).resize(function() {
inViewport();
});
function getCurrentScroll() {
return window.pageYOffset - $('section.section2').offset().top;
};
function inViewport() {
$('section.section2').each(function() {
var divPos = $(this).offset().top;
var divHeight = $(this).height() * 1.4;
var topOfWindow = $(window).scrollTop();
if (divPos < topOfWindow + 50) {
var scrolls = getCurrentScroll() / 4;
$(this).find('.circle').css('width',scrolls+'%');
$(this).find('.circle').css('height',scrolls*2+'%');
$(this).find('.img-box').css('transform','translateY('+(topOfWindow / (15))+'%)');
}
if (divPos + 100 < topOfWindow ) {
$(this).find('.desc').css('transform','translateY('+(-topOfWindow / (10))+'%)');
$(this).find('.img-box').css('transform','translateY('+(topOfWindow / (10))+'%)');
}
});
}
section.section1{
height:500px;
width:100%
}
section.section2 {
padding: 150px 0;
position: relative;
height: 170vh;
overflow: hidden;
}
section.section2 .circle{
position: fixed;
height: 0%;
width: 0%;
left: -50%;
top: 0;
bottom: 0;
right: -50%;
margin:auto;
background:#000;
border-radius: 100%;
transition:ease all 0.25s;
margin:auto;
z-index:-1
}
section.section2 .desc p {
max-width: 50%;
margin: auto;
font-size: 16px;
font-family: arial,sans-serif;
color: rgb(70, 70, 70);
line-height: 1.563;
text-align: center;
}
section.section2 .desc{
transition: ease all 0.25s;
}
section.section2 .img-box {
text-align: center;
margin-top: 50px;
margin-bottom: -110px;
transition: ease all 0.25s;
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
display: flex;
justify-content: center;
align-items: center;
transform:translateY(400%);
}
section.section2 .img-box svg {
width: 100px;
display: block;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<section class="section1">
</section>
<section class="section2">
<div class="container">
<div class="desc">
<p>This is dummy copy. It is not meant to be read. It has been placed here solely to demonstrate the look and feel of finished, typeset text. Only for show. He who searches for meaning here will be sorely disappointed. These words are here to the reader.</p>
</div>
<div class="img-box">
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 195.8 190" viewBox="0 0 195.8 190">
<path
d="m68.7 111.3v-35h3.5l16.3 29.2v-29.2h2.5v35h-3.5l-16.3-29v29zm40.3-23.9c-.4 1-.9 1.9-1.5 2.7-.6.7-1.4 1.3-2.4 1.8-.9.5-1.9.7-2.9.7s-2.1-.2-2.9-.7-1.8-1.2-2.3-1.8c-.7-.9-1.2-1.8-1.6-2.7-.4-1.1-.6-2.2-.6-3.4s.2-2.3.6-3.4c.4-.9.9-1.8 1.6-2.7.5-.8 1.4-1.4 2.3-1.8.9-.5 1.9-.6 2.9-.6 1.1 0 2.1.2 2.9.6.9.5 1.8 1.1 2.4 1.8.6.8 1.2 1.7 1.5 2.7.4 1.1.6 2.2.6 3.4s-.2 2.3-.6 3.4zm-13.4 12.9v-2.8h13.4v2.8zm2.2-16.3c0 2 .4 3.4 1.2 4.4.9 1 1.9 1.5 3.2 1.5s2.4-.5 3.2-1.6c.8-1 1.2-2.5 1.2-4.5s-.4-3.5-1.2-4.5c-.8-1.1-1.9-1.6-3.2-1.6s-2.4.5-3.1 1.5c-.8 1-1.2 2.5-1.2 4.4z"
fill="#fff" />
<path d="m123.7 76.3v35h-3.8v-30.3c-2 1.8-4.3 3.6-6.2 5.3l-1.1-2.1 8.7-7.8z" fill="#fff" />
<g fill="none" stroke="#fff" stroke-miterlimit="10">
<path d="m0 85.8h36.3" />
<path d="m0 102.9h36.3" />
<path d="m159.5 85.8h36.3" />
<path d="m159.5 102.9h36.3" />
</g>
<g fill="#fff">
<path d="m162.8 96.6h1.6v-4.5c0-.2 0-.4 0-.4s-.1.2-.3.4l-.7.6-.6-.6 1.7-1.6h.9v6.2h1.5v.9h-4.1z" />
<path
d="m170.3 96.5c.2.1.6.2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m28 96.5h1v1h-1z" />
<path d="m33.3 146 1.7 2-10.8 9.2-1.7-2z" />
<path
d="m39.3 152.9 2 1.7-1.2 9.7c-.1 1-.5 2.4-.5 2.4s.8-1.1 1.3-1.8l5.3-6.3 2 1.7-9.2 10.9-2-1.7 1.2-9.7c.1-1 .5-2.4.5-2.4s-.8 1.1-1.3 1.8l-5.3 6.2-2-1.7z" />
<path
d="m53.4 163.9 2.3 1.2.9 9.8c.1 1 0 2.5 0 2.5s.5-1.3.9-2l3.8-7.3 2.3 1.2-6.6 12.6-2.3-1.2-1-9.7c-.1-1 0-2.5 0-2.5s-.5 1.3-.9 2l-3.8 7.2-2.3-1.2z" />
<path
d="m75.8 173c4.2 1.1 6.3 4.9 5.3 8.9-1.1 4-4.8 6.4-9 5.3s-6.3-5-5.2-9.1c1-3.8 4.7-6.1 8.9-5.1zm-3.1 12c2.6.7 5.1-.9 5.8-3.7.7-2.7-.7-5.2-3.3-5.9s-5.1.9-5.8 3.5c-.7 2.7.6 5.4 3.3 6.1z" />
<path d="m86.3 175.5 2.8.1 2.7 9.4c.2.8.5 2.1.5 2.1s.3-1.2.6-2.1l3.6-9.1 2.7.1-5.7 14-2.7-.1z" />
<path
d="m106.6 175.2 2.7-.4 7 13.3-2.6.4-1.7-3.4-4.9.7-.7 3.8-2.6.4zm4.4 8-1.8-3.6c-.4-.8-.9-2.1-.9-2.1s-.1 1.4-.2 2.3l-.7 3.9z" />
<path d="m121.6 174.2-4.4 1.5-.7-2.1 11.3-3.8.7 2.1-4.4 1.5 3.8 11.4-2.4.8z" />
<path d="m132.4 167.5 2.3-1.2 6.5 12.6-2.3 1.2z" />
<path
d="m145.4 159.1c3.4-2.6 7.8-1.9 10.2 1.3 2.5 3.3 2.1 7.8-1.3 10.4s-7.8 1.9-10.3-1.5c-2.5-3.2-2-7.6 1.4-10.2zm7.5 9.8c2.2-1.7 2.4-4.6.6-6.9-1.7-2.2-4.5-2.7-6.7-1-2.2 1.6-2.4 4.5-.8 6.7 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.7 2.1-8.3-2.6z" />
<path
d="m141.9 11.7c3.8 2.1 4.9 6.3 3 9.9-2 3.7-6.2 5.1-10 3s-4.9-6.4-2.9-10.1c1.9-3.5 6.1-4.9 9.9-2.8zm-6 10.8c2.4 1.3 5.2.3 6.5-2.2 1.3-2.4.6-5.2-1.8-6.5s-5.1-.4-6.5 2c-1.2 2.5-.6 5.4 1.8 6.7z" />
<path
d="m159.7 24.4c1.4 1.2 2.5 2.9 2.8 4.9l-2.2.6c-.1-1.2-.9-2.6-1.9-3.5-2.4-2.1-5.1-1.6-6.9.4-2 2.3-1.8 5.2.2 7 1 .9 2.3 1.3 3.6 1.3l1.1-1.2-1.6-1.4 1.5-1.7 3.4 3-5 5.6-1.6-1.5.5-.5c.2-.2.4-.4.4-.4-1.3.1-2.9-.5-4.1-1.6-2.8-2.5-3.3-6.8-.3-10.1 2.5-3.4 6.9-3.7 10.1-.9z" />
<path
d="m164.2 41.6 3.7-8.8 1.8 2.3-2 4.3c-.4.9-1 1.8-1 1.8s1.1-.3 2-.5l4.7-.8 1.8 2.3-9.4 1.2-4.7 3.6-1.6-2z" />
</g>
</svg>
</div>
<div class="circle">
</div>
</div>
</section>

How can I change the color of the check mark in this svg?

1) Is there a way to change the color of the checkmark in this svg?
2) Why is fill:rgb(71,131,48); working but fill:#478530; not?
3) If I want to create other symbols inside of the cloud, are there any tools out there to do that?
.icon {
background: url('data:image/svg+xml;utf8,<svg id="icon-cloud-check" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><path style="fill:rgb(71,131,48);" d="M27.883 16.078c0.076-0.347 0.117-0.708 0.117-1.078 0-2.761-2.239-5-5-5-0.445 0-0.875 0.058-1.285 0.167-0.775-2.417-3.040-4.167-5.715-4.167-2.73 0-5.033 1.823-5.76 4.318-0.711-0.207-1.462-0.318-2.24-0.318-4.418 0-8 3.582-8 8s3.582 8 8 8h19c2.761 0 5-2.239 5-5 0-2.46-1.777-4.505-4.117-4.922zM13 24l-5-5 2-2 3 3 7-7 2 2-9 9z"></path></svg>') no-repeat;
}
<svg class="icon"></svg>
And idea is to use another background as a bottom layer:
.icon {
background:
url('data:image/svg+xml;utf8,<svg id="icon-cloud-check" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><path style="fill:rgb(71,131,48);" d="M27.883 16.078c0.076-0.347 0.117-0.708 0.117-1.078 0-2.761-2.239-5-5-5-0.445 0-0.875 0.058-1.285 0.167-0.775-2.417-3.040-4.167-5.715-4.167-2.73 0-5.033 1.823-5.76 4.318-0.711-0.207-1.462-0.318-2.24-0.318-4.418 0-8 3.582-8 8s3.582 8 8 8h19c2.761 0 5-2.239 5-5 0-2.46-1.777-4.505-4.117-4.922zM13 24l-5-5 2-2 3 3 7-7 2 2-9 9z"></path></svg>') no-repeat,
linear-gradient(red,red)50% 60%/50% 40% no-repeat;
display:inline-block;
width:150px;
height:150px;
}
<svg class="icon"></svg>
<svg class="icon" style="width:100px;height:100px;"></svg>
You need to url encode the # symbol
Use fill: %23478530
.icon {
background: url('data:image/svg+xml;utf8,<svg id="icon-cloud-check" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><path style="fill:%23478530;" d="M27.883 16.078c0.076-0.347 0.117-0.708 0.117-1.078 0-2.761-2.239-5-5-5-0.445 0-0.875 0.058-1.285 0.167-0.775-2.417-3.040-4.167-5.715-4.167-2.73 0-5.033 1.823-5.76 4.318-0.711-0.207-1.462-0.318-2.24-0.318-4.418 0-8 3.582-8 8s3.582 8 8 8h19c2.761 0 5-2.239 5-5 0-2.46-1.777-4.505-4.117-4.922zM13 24l-5-5 2-2 3 3 7-7 2 2-9 9z"></path></svg>') no-repeat;
}
<svg class="icon"></svg>

What's the best way to center an SVG horizontally and vertically inside a div tag?

What's the best way to center an SVG horizontally and vertically an SVG inside a div tag?
I know some ways are better than others, but for this what would be the best way of doing it?
<div style="width: 64px;height: 64px;background-color: rgba(0,0,0,.7);background-repeat: no-repeat;background-size: 24px;background-position: 58% 50%;border-radius: 500px;border: 1px solid blue;cursor: pointer;">
<svg viewBox="-22 0 1229 1481" width="24" height="29" style="display:block;margin: 0 auto;background-color:green;">
<path d="M0 1394V87C0 46.3 13.3 19.8 40 7.5 66.7-4.8 98.7.3 136 23l1034 634c37.3 22.7 56 50.3 56 83s-18.7 60.3-56 83L136 1458c-37.3 22.7-69.3 27.8-96 15.5-26.7-12.3-40-38.8-40-79.5z" fill="red"/>
</svg>
</div>
If you plan on setting fixed positions, pixel sizes and margins yourself, just adjust the svg vertical margin.
<div style="width: 64px;height: 64px;background-color: rgba(0,0,0,.7);background-repeat: no-repeat;background-size: 24px;background-position: 58% 50%;border-radius: 500px;border: 1px solid blue;cursor: pointer;">
<svg viewBox="-22 0 1229 1481" width="24" height="29" style="display:block;margin:16px auto;background-color:green;">
<path d="M0 1394V87C0 46.3 13.3 19.8 40 7.5 66.7-4.8 98.7.3 136 23l1034 634c37.3 22.7 56 50.3 56 83s-18.7 60.3-56 83L136 1458c-37.3 22.7-69.3 27.8-96 15.5-26.7-12.3-40-38.8-40-79.5z" fill="red"/>
</svg>
</div>
use this css style for your SVG element
margin: 0 auto;
display: block;
and this css for DIV element
display: flex;
align-items: center;
height: 100%;