HTML - Center List and icon to bottom - html

I'm starting to using css grid and flex box but I have a problem trying to align this list to the center.
Here is the codepen and snippet:
* {
box-sizing: border-box;
}
.container-shell {
background: gray;
display: -ms-grid;
display: grid;
grid-template-areas: "nav content content";
-ms-grid-columns: 60px 1fr;
grid-template-columns: 60px 1fr;
-ms-grid-rows: auto;
grid-template-rows: auto;
height: 100vh;
}
nav {
-ms-grid-row: 1;
-ms-grid-column: 1;
grid-area: nav;
background-color: #fff;
}
main {
-ms-grid-row: 1;
-ms-grid-column: 2;
-ms-grid-column-span: 2;
grid-area: content;
}
.navigation-container {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
}
.navigation-flex-item {
flex: 1 0 50%;
text-align: center;
padding: 10px;
min-width: 0;
}
ul {
list-style: none;
margin: 0;
}
.--no-padding {
padding: 0 !important;
}
.--bottom {
align-self: flex-end;
}
.navbar-toggle {
margin: 14px 5px 14px 0 !important;
border: 0 !important;
transition: all .1s linear !important;
cursor: pointer;
}
.navbar-toggle {
position: relative;
float: right;
margin-right: 15px;
padding: 9px 10px;
margin-top: 33px;
margin-bottom: 33px;
background-color: transparent;
background-image: none;
border: 1px solid transparent;
border-radius: 4px;
}
.sr-only {
border: 0;
clip: rect(0, 0, 0, 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
padding: 0;
overflow: hidden;
clip: rec(0, 0, 0, 0);
border: 0;
}
.icon-bar {
display: block;
width: 22px;
height: 2px;
border-radius: 1px;
background-color: #888;
}
.icon-bar {
width: 30px;
height: 3px;
background-color: #000;
border-radius: 0;
-webkit-transform-origin: 50% 50%;
transform-origin: 50% 50%;
transition: all .1s linear;
-webkit-transform: rotate(0);
transform: rotate(0);
}
.icon-bar:nth-child(2) {
width: 19px;
margin-left: 11px;
}
.icon-bar + .icon-bar {
margin-top: 4px;
}
.icon-bar:last-of-type {
width: 19px;
margin-right: 11px;
}
<div class="container-shell">
<nav>
<div style="height: 100%">
<div class="navigation-container">
<ul class="navigation-flex-item">
<li>1</li>
<li>2</li>
<li><svg _ngcontent-c2="" xml:space="preserve" xmlns:xlink="http://www.w3.org/1999/xlink" id="Capa_1" style="enable-background:new 0 0 60 60;" version="1.1" viewBox="0 0 60 60" x="0px" xmlns="http://www.w3.org/2000/svg" y="0px">
<g _ngcontent-c2="">
<path _ngcontent-c2="" d="M57,4h-7V1c0-0.553-0.447-1-1-1h-7c-0.553,0-1,0.447-1,1v3H19V1c0-0.553-0.447-1-1-1h-7c-0.553,0-1,0.447-1,1v3H3
C2.447,4,2,4.447,2,5v11v43c0,0.553,0.447,1,1,1h54c0.553,0,1-0.447,1-1V16V5C58,4.447,57.553,4,57,4z M43,2h5v3v3h-5V5V2z M12,2h5
v3v3h-5V5V2z M4,6h6v3c0,0.553,0.447,1,1,1h7c0.553,0,1-0.447,1-1V6h22v3c0,0.553,0.447,1,1,1h7c0.553,0,1-0.447,1-1V6h6v9H4V6z
M4,58V17h52v41H4z"></path>
<path _ngcontent-c2="" d="M38,23h-7h-2h-7h-2h-9v9v2v7v2v9h9h2h7h2h7h2h9v-9v-2v-7v-2v-9h-9H38z M31,25h7v7h-7V25z M38,41h-7v-7h7V41z M22,34h7v7h-7
V34z M22,25h7v7h-7V25z M13,25h7v7h-7V25z M13,34h7v7h-7V34z M20,50h-7v-7h7V50z M29,50h-7v-7h7V50z M38,50h-7v-7h7V50z M47,50h-7
v-7h7V50z M47,41h-7v-7h7V41z M47,25v7h-7v-7H47z"></path>
</g><g _ngcontent-c2="">
</g>
<g _ngcontent-c2="">
</g>
<g _ngcontent-c2="">
</g>
<g _ngcontent-c2="">
</g>
<g _ngcontent-c2="">
</g>
<g _ngcontent-c2="">
</g>
<g _ngcontent-c2="">
</g>
<g _ngcontent-c2="">
</g>
<g _ngcontent-c2="">
</g>
<g _ngcontent-c2="">
</g>
<g _ngcontent-c2="">
</g>
<g _ngcontent-c2="">
</g>
<g _ngcontent-c2="">
</g>
<g _ngcontent-c2="">
</g>
<g _ngcontent-c2="">
</g>
</svg>
</li>
</ul>
<div class="navigation-flex-item --bottom --no-padding">
<button class="navbar-toggle">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
</div>
</div>
</nav>
<main>
Hello World Content!
</main>
</div>
As you can see the hamburger icon aligned to the center which is fine but the text (list) is aligned to the left, how can I center the text and the image without break the hamburger icon. I already tried with align and justify.

Have made the below changes to your code:
The default flex-direction is row - you have to change it to column for the navigation-container.
Remove flex: 1 0 50% from the element navigation-flex-item.
Absolutely position the hamburger to the bottom.
See code below:
* {
box-sizing: border-box;
}
body {
background: blue; /* for illustration */
}
.container-shell {
background: gray;
display: -ms-grid;
display: grid;
grid-template-areas: "nav content content";
-ms-grid-columns: 60px 1fr;
grid-template-columns: 60px 1fr;
-ms-grid-rows: auto;
grid-template-rows: auto;
height: 100vh;
}
nav {
-ms-grid-row: 1;
-ms-grid-column: 1;
grid-area: nav;
background-color: #fff;
}
main {
-ms-grid-row: 1;
-ms-grid-column: 2;
-ms-grid-column-span: 2;
grid-area: content;
}
.navigation-container {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column; /* ADDED */
height: 100%;
}
.navigation-flex-item {
/*flex: 1 0 50%;*/
text-align: center;
padding: 10px;
min-width: 0;
}
ul {
list-style: none;
margin: 0;
}
.--no-padding {
padding: 0 !important;
}
.--bottom {
/*align-self: flex-end;*/
position: absolute; /* ADDED */
bottom: 0; /* ADDED */
}
.navbar-toggle {
margin: 14px 5px 14px 0 !important;
border: 0 !important;
transition: all .1s linear !important;
cursor: pointer;
}
.navbar-toggle {
position: relative;
float: right;
margin-right: 15px;
padding: 9px 10px;
margin-top: 33px;
margin-bottom: 33px;
background-color: transparent;
background-image: none;
border: 1px solid transparent;
border-radius: 4px;
}
.sr-only {
border: 0;
clip: rect(0, 0, 0, 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
padding: 0;
overflow: hidden;
clip: rec(0, 0, 0, 0);
border: 0;
}
.icon-bar {
display: block;
width: 22px;
height: 2px;
border-radius: 1px;
background-color: #888;
}
.icon-bar {
width: 30px;
height: 3px;
background-color: #000;
border-radius: 0;
-webkit-transform-origin: 50% 50%;
transform-origin: 50% 50%;
transition: all .1s linear;
-webkit-transform: rotate(0);
transform: rotate(0);
}
.icon-bar:nth-child(2) {
width: 19px;
margin-left: 11px;
}
.icon-bar+.icon-bar {
margin-top: 4px;
}
.icon-bar:last-of-type {
width: 19px;
margin-right: 11px;
}
<div class="container-shell">
<nav>
<div style="height: 100%">
<div class="navigation-container">
<ul class="navigation-flex-item">
<li>1</li>
<li>2</li>
<li><svg _ngcontent-c2="" xml:space="preserve" xmlns:xlink="http://www.w3.org/1999/xlink" id="Capa_1" style="enable-background:new 0 0 60 60;" version="1.1" viewBox="0 0 60 60" x="0px" xmlns="http://www.w3.org/2000/svg" y="0px">
<g _ngcontent-c2="">
<path _ngcontent-c2="" d="M57,4h-7V1c0-0.553-0.447-1-1-1h-7c-0.553,0-1,0.447-1,1v3H19V1c0-0.553-0.447-1-1-1h-7c-0.553,0-1,0.447-1,1v3H3
C2.447,4,2,4.447,2,5v11v43c0,0.553,0.447,1,1,1h54c0.553,0,1-0.447,1-1V16V5C58,4.447,57.553,4,57,4z M43,2h5v3v3h-5V5V2z M12,2h5
v3v3h-5V5V2z M4,6h6v3c0,0.553,0.447,1,1,1h7c0.553,0,1-0.447,1-1V6h22v3c0,0.553,0.447,1,1,1h7c0.553,0,1-0.447,1-1V6h6v9H4V6z
M4,58V17h52v41H4z"></path>
<path _ngcontent-c2="" d="M38,23h-7h-2h-7h-2h-9v9v2v7v2v9h9h2h7h2h7h2h9v-9v-2v-7v-2v-9h-9H38z M31,25h7v7h-7V25z M38,41h-7v-7h7V41z M22,34h7v7h-7
V34z M22,25h7v7h-7V25z M13,25h7v7h-7V25z M13,34h7v7h-7V34z M20,50h-7v-7h7V50z M29,50h-7v-7h7V50z M38,50h-7v-7h7V50z M47,50h-7
v-7h7V50z M47,41h-7v-7h7V41z M47,25v7h-7v-7H47z"></path>
</g><g _ngcontent-c2="">
</g>
<g _ngcontent-c2="">
</g>
<g _ngcontent-c2="">
</g>
<g _ngcontent-c2="">
</g>
<g _ngcontent-c2="">
</g>
<g _ngcontent-c2="">
</g>
<g _ngcontent-c2="">
</g>
<g _ngcontent-c2="">
</g>
<g _ngcontent-c2="">
</g>
<g _ngcontent-c2="">
</g>
<g _ngcontent-c2="">
</g>
<g _ngcontent-c2="">
</g>
<g _ngcontent-c2="">
</g>
<g _ngcontent-c2="">
</g>
<g _ngcontent-c2="">
</g>
</svg>
</li>
</ul>
<div class="navigation-flex-item --bottom --no-padding">
<button class="navbar-toggle">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
</div>
</div>
</nav>
<main>
Hello World Content!
</main>
</div>

Related

How to add an arrow at the end of the lines

I actually have some styles that allow me to display a text surrounded by lines. The text can be displayed horizontally or vertically. I would like to add an arrow a the end of the surrounding lines. Something like this:
------------------------- My horizontal label ------------------------>
or
^
|
|
M
y
t
e
x
t
|
|
My vertical text is displayed differently in my following example.
I tried several Technics i found in the net but no way to make it work in horizontal and vertical context.
Someone has an idea of how it can be implemented?
This is my starting css in which i would like to add these arrows:
h1 {
display: flex;
flex-direction: row;
}
h1:before, h1:after{
content: "";
flex: 1 1;
border-bottom: 1px solid;
margin: auto;
}
h1:before {
margin-right: 10px
}
h1:after {
margin-left: 10px
}
h2 {
display: flex;
flex-direction: row;
writing-mode: vertical-rl;
transform: scale(-1);
text-align: -webkit-center;
height: 100%;
}
h2:before, h2:after{
content: "";
flex: 1 1;
border-right: 1px solid;
margin: auto;
}
h2:before {
margin-bottom: 10px
}
h2:after {
margin-top: 10px
}
<h1>My horizontal text</h1>
<h2>My vertical text</h2>
Thank you for your solution. I tried this that seems to be nice too:
.line-container {
display: flex;
width: 100%;
margin: 20px auto;
align-items: center;
}
.line {
flex-grow: 1;
height: 2px;
background: black;
position: relative;
}
.line.arrow-right:after {
position: absolute;
content: '';
bottom: -4px;
right: -1px;
width: 0;
height: 0;
border-top: 5px solid transparent;
border-bottom: 5px solid transparent;
border-left: 10px solid black;
}
.line-container span.label {
margin: 0 10px;
}
.line-container-vertical {
display: flex;
height: 100%;
margin: auto 20px;
align-items: center;
writing-mode: vertical-rl;
transform: scale(-1);
}
.line-vertical {
flex-grow: 1;
width: 2px;
background: black;
position: relative;
}
.line-vertical.arrow-top:after {
position: absolute;
content: '';
bottom: -2px;
left: -4px;
width: 0;
height: 0;
border-top: 10px solid black;
border-right: 5px solid transparent;
border-left: 5px solid transparent;
}
.line-container-vertical span.label {
margin: 10px 0;
}
<div class="line-container">
<span class="line arrow-left"></span>
<span class="label">Horizontal Label</span>
<span class="line arrow-right"></span>
</div>
<div class="line-container-vertical">
<span class="line-vertical"></span>
<span class="label">Vertical Label</span>
<span class="line-vertical arrow-top"></span>
</div>
What do you think?
[EDIT 20221125 - Added an alternative approach]
I am not all sure that your approach is the best, but based on your approach, the following might be of use:
h1 {
display: flex;
flex-direction: row;
}
h1 > div:nth-of-type(1) {
margin-right: -0.05em;
}
h1 > div:nth-of-type(2),
h1 > div:nth-of-type(4) {
flex: 1 1;
border-bottom: 0.05em solid;
margin: auto;
padding-top: 0.17em;
}
h1 > div:nth-of-type(3) {
margin-right: 10px;
margin-left: 10px;
}
h1 > div:nth-of-type(5) {
margin-left: -0.05em;
}
h2 {
display: flex;
flex-direction: row;
writing-mode: vertical-rl;
transform: scale(-1);
height: 100%;
}
h2 > div:nth-of-type(1) {
margin-bottom: -0.05em;
}
h2 > div:nth-of-type(2),
h2 > div:nth-of-type(4) {
flex: 1 1;
border-left: 0.05em solid;
margin: auto;
padding-left: 0.17em;
margin-top: -0.05em;
margin-bottom: -0.05em;
}
h2 > div:nth-of-type(3) {
margin-top: 10px;
margin-bottom: 10px;
}
h2 > div:nth-of-type(5) {
margin-bottom: -0.05em;
}
<h1><div>←</div><div></div><div>My horizontal text</div><div></div><div>→</div></h1>
<h2><div>←</div><div></div><div>My vertical text</div><div></div><div>→</div></h2>
The following is an alternative approach and should be more robust:
.horizontal {
display: flex;
flex-direction: row;
justify-content: space-between;
background-repeat: repeat-x;
background-position-y: center;
background-image: url('data:image/svg+xml; utf8, <svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none" viewBox="0 0 20 3"><line x1="0" y1="1" x2="20" y2="1" stroke="black" stroke-width="3" /></svg>');
background-size: 100% 0.2em;
}
.horizontal > span {
background: white;
padding-left: 10px;
padding-right: 10px;
font-weight: bold;
}
leftarrow {
content: url('data:image/svg+xml; utf8, <svg xmlns="http://www.w3.org/2000/svg" height="1.1em" viewBox="0 0 40 14"><line x1="0" y1="7" x2="38" y2="2" stroke="black" stroke-width="2" /><line x1="0" y1="7" x2="38" y2="12" stroke="black" stroke-width="2" /></svg>');
}
rightarrow {
content: url('data:image/svg+xml; utf8, <svg xmlns="http://www.w3.org/2000/svg" height="1.1em" viewBox="0 0 40 14"><line x1="1" y1="2" x2="39" y2="7" stroke="black" stroke-width="2" /><line x1="1" y1="12" x2="39" y2="7" stroke="black" stroke-width="2" /></svg>');
}
<div class="horizontal"><leftarrow></leftarrow><span>Horizontally aligned text</span><rightarrow></rightarrow></div>

How can I make this button with css

I'm trying to make this button that have a circle shape inside and contains this arrow icon.
My idea is when you hover it, the whole button became colored inside
<div class="col-12">
<div style="border: 1px solid #583F99; width: 180px; height: 40px; border-radius: 30px;">
<span class="class justify-content-center" style="">read more</span>
<div style="border: 1px solid #583F99; border-radius: 30px; width: 38px; height: 38px; position: absolute;">
<img src="img/arrow.svg" style="width: 18px;" />
</div>
</div>
</div>
.button {
border: 1px solid #583F99;
width: 180px;
height: 40px;
border-radius: 40px;
display: flex;
align-items: center;
justify-content: space-between;
transition: .4s;
}
.icon {
border-radius: 40px;
display: block;
width: 20px;
height: 20px;
padding: 10px;
background-color: #583F99;
transition: .4s;
}
.title {
color: #583F99;
font-family: sans-serif;
font-size: 130%;
flex: 1;
text-align: center;
}
.button:hover {
background-color: #583F99;
}
.button:hover .title {
color: white;
}
.button:hover .icon {
transform: rotate(-90deg);
}
<div class="button">
<span class="title">read more</span>
<img class="icon" src="data:image/svg+xml,%3Csvg fill='%23ffffff' xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M0 7.33l2.829-2.83 9.175 9.339 9.167-9.339 2.829 2.83-11.996 12.17z'/%3E%3C/svg%3E">
</div>
Here it is. If you have any questions, please tell me so I can explain it to you.
.button {
height: 22px;
border: 1px solid rgb(128, 0, 128);
display: inline-flex;
align-items: center;
border-radius: 15px;
overflow: hidden;
cursor: pointer;
}
.button:hover {
background-color: rgb(128, 0, 128);
}
.button__text {
color: rgb(128, 0, 128);
padding: 5 10px;
margin-right: 5px;
}
.button:hover .button__text {
color: rgb(255, 255, 255);
}
.button__chevron_down_icon {
background-color: rgb(128, 0, 128);
color: rgb(255, 255, 255);
width: 22px;
height: 22px;
border-top-left-radius: 50%;
border-bottom-left-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
}
.button__chevron_down_icon>svg+svg {
display: none;
}
.button:hover .button__chevron_down_icon>svg {
display: none;
}
.button:hover .button__chevron_down_icon>svg+svg {
display: block;
}
<div class="button">
<div class="button__text">read more</div>
<div class="button__chevron_down_icon">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M8.25 4.5l7.5 7.5-7.5 7.5" />
</svg>
</div>
</div>

zoom works only in chrome , scale ruins the graphic

I have this structure and it works perfectly only in chrome!!:
.audio-controls {
display: none;
flex-direction: row;
gap: 1226px;
justify-content: center;
width: 100%;
position: absolute;
top: 82%;
left: 0%;
z-index: 99;
}
.prompt {
height: 100%;
display: flex;
justify-content: center;
align-items: center;
cursor: not-allowed;
background: #000000;
border-radius: 35px;
}
.prompt .stim {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 124px;
width: 126px;
border-radius: 30%;
background: linear-gradient(#1f1f20, #040404);
transform: translateY(-6px);
overflow: hidden;
box-shadow: 0px 9px 3px #000000, 0 10px 20px rgb(0 0 0 / 25%);
}
.prompt .stim::before {
content: "";
opacity: 0.35;
top: 0;
left: 0;
bottom: 0;
right: 0;
position: absolute;
background-image: url(../img/hexellence.png);
}
.audio-controls .record {
transform: translate(0px, 40px);
zoom: 0.042;
}
.prompt .stim p {
transition: color 0.05s ease;
}
.stim p {
color: #b9b7b7;
font-family: "Open Sans Regular";
font-size: .7em;
margin-bottom: 4px;
transition: color 0.1s ease-in-out;
z-index: 1;
}
<div class="audio-controls" style="display: flex;">
<div id="start-recognition" class="prompt activated">
<div class="record-dot record-dot-position on" style="transform: translateY(-6px);"></div>
<div class="record-dot-container record-dot-position" style="transform: translateY(-6px);"></div>
<div class="stim">
<svg class="record" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" enable-background="new 0 0 1000 1000" xml:space="preserve" style="fill: rgb(123, 55, 32);" width="1000" height="1000">
<rect id="backgroundrect" width="100%" height="100%" x="0" y="0" fill="none" stroke="none"></rect>
<g class="currentLayer" style="">
<g id="svg_1" class="selected" fill="#dadada" fill-opacity="1">
<path d="M500,683.8c84.6,0,153.1-68.6,153.1-153.1V163.1C653.1,78.6,584.6,10,500,10c-84.6,0-153.1,68.6-153.1,153.1v367.5C346.9,615.2,415.4,683.8,500,683.8z M714.4,438.8v91.9C714.4,649,618.4,745,500,745c-118.4,0-214.4-96-214.4-214.4v-91.9h-61.3v91.9c0,141.9,107.2,258.7,245,273.9v124.2H346.9V990h306.3v-61.3H530.6V804.5c137.8-15.2,245-132.1,245-273.9v-91.9H714.4z" id="record-icon" fill="#dadada57" style="fill: rgba(218, 218, 218, 0.34);"></path>
</g>
</g>
</svg>
<p id="record-icon-text" style="color: rgb(185, 183, 183);">Hold Space Key</p>
</div>
</div>
</div>
The issue is in the above code I used zoom here:
.audio-controls .record {
transform: translate(0px, 40px);
zoom: 0.042;
}
And zoom is not working in Firefox so it only works in chrome.
In order to make this work I need to use scale instead right? I used scale in the below snippet but I ruined the graphic !
Have a look: ( I only removed zoom and replaces scale here)
.audio-controls {
display: none;
flex-direction: row;
gap: 1226px;
justify-content: center;
width: 100%;
position: absolute;
top: 82%;
left: 0%;
z-index: 99;
}
.prompt {
height: 100%;
display: flex;
justify-content: center;
align-items: center;
cursor: not-allowed;
background: #000000;
border-radius: 35px;
}
.prompt .stim {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 124px;
width: 126px;
border-radius: 30%;
background: linear-gradient(#1f1f20, #040404);
transform: translateY(-6px);
overflow: hidden;
box-shadow: 0px 9px 3px #000000, 0 10px 20px rgb(0 0 0 / 25%);
}
.prompt .stim::before {
content: "";
opacity: 0.35;
top: 0;
left: 0;
bottom: 0;
right: 0;
position: absolute;
background-image: url(../img/hexellence.png);
}
.audio-controls .record {
transform: scale(0.042) translate(0px, 40px);
/*zoom: 0.042;*/
}
.prompt .stim p {
transition: color 0.05s ease;
}
.stim p {
color: #b9b7b7;
font-family: "Open Sans Regular";
font-size: .7em;
margin-bottom: 4px;
transition: color 0.1s ease-in-out;
z-index: 1;
}
<div class="audio-controls" style="display: flex;">
<div id="start-recognition" class="prompt activated">
<div class="record-dot record-dot-position on" style="transform: translateY(-6px);"></div>
<div class="record-dot-container record-dot-position" style="transform: translateY(-6px);"></div>
<div class="stim">
<svg class="record" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" enable-background="new 0 0 1000 1000" xml:space="preserve" style="fill: rgb(123, 55, 32);" width="1000" height="1000">
<rect id="backgroundrect" width="100%" height="100%" x="0" y="0" fill="none" stroke="none"></rect>
<g class="currentLayer" style="">
<g id="svg_1" class="selected" fill="#dadada" fill-opacity="1">
<path d="M500,683.8c84.6,0,153.1-68.6,153.1-153.1V163.1C653.1,78.6,584.6,10,500,10c-84.6,0-153.1,68.6-153.1,153.1v367.5C346.9,615.2,415.4,683.8,500,683.8z M714.4,438.8v91.9C714.4,649,618.4,745,500,745c-118.4,0-214.4-96-214.4-214.4v-91.9h-61.3v91.9c0,141.9,107.2,258.7,245,273.9v124.2H346.9V990h306.3v-61.3H530.6V804.5c137.8-15.2,245-132.1,245-273.9v-91.9H714.4z" id="record-icon" fill="#dadada57" style="fill: rgba(218, 218, 218, 0.34);"></path>
</g>
</g>
</svg>
<p id="record-icon-text" style="color: rgb(185, 183, 183);">Hold Space Key</p>
</div>
</div>
</div>
How can I fix using scale ?

Shift cards over to next row when browser size is 915px width

How do I shift the content over to the next row when browser width is 915px?
This is what I have now:
<div class="body">
<div class="container">
<div class="card">
<div class="box">
<div class="percent">
<svg>
<circle cx="70" cy="70" r="70"></circle>
<circle cx="70" cy="70" r="70"></circle>
</svg>
<div class="number">
<h2>90<span>%</span></h2>
</div>
</div>
<h2 class="text">Html</h2>
</div>
</div>
<div class="card">
<div class="box">
<div class="percent">
<svg>
<circle cx="70" cy="70" r="70"></circle>
<circle cx="70" cy="70" r="70"></circle>
</svg>
<div class="number">
<h2>85<span>%</span></h2>
</div>
</div>
<h2 class="text">CSS</h2>
</div>
</div>
<div class="card">
<div class="box">
<div class="percent">
<svg>
<circle cx="70" cy="70" r="70"></circle>
<circle cx="70" cy="70" r="70"></circle>
</svg>
<div class="number">
<h2>60<span>%</span></h2>
</div>
</div>
<h2 class="text">Javascript</h2>
</div>
</div>
</div>
</div>
And my css
.body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.container {
display: flex;
justify-content: space-around;
}
.container .card {
margin-left: 20px;
position: relative;
width: 250px;
background: #222;
background: linear-gradient(0deg, #1b1b1b, #222, #1b1b1b);
display: flex;
justify-content: center;
align-items: center;
height: 300px;
border-radius: 4px;
text-align: center;
overflow: hidden;
transition: 0.5s;
}
.container .card:hover {
box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
transform: translateY(-10px);
}
.container .card:before {
content: "";
position: absolute;
top: 0;
left: -50%;
width: 100%;
height: 100%;
background: rgba(255, 255, 255, 0.03);
pointer-events: none;
z-index: 1;
}
.percent {
position: relative;
width: 150px;
height: 150px;
border-radius: 50%;
box-shadow: inset 0 0 50px #000;
background: #222;
z-index: 100;
}
.percent .number {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
border-radius: 50%;
}
.percent .number h2 {
color: #777;
font-weight: 700;
font-size: 40px;
transition: 0.5s;
}
.card:hover .percent .number h2 {
color: #fff;
font-size: 60px;
}
.percent .number h2 span {
font-size: 24px;
color: #777;
}
.text {
color: #777;
margin-top: 20px;
font-weight: 700;
font-size: 18px;
letter-spacing: 1px;
text-transform: uppercase;
transition: 0.5s;
}
.card:hover .text {
color: #fff;
}
svg {
position: relative;
width: 150px;
height: 150px;
z-index: 1000;
}
circle {
width: 100%;
height: 100%;
fill: none;
stroke: #191919;
stroke-width: 10;
stroke-linecap: round;
transform: translate(5px, 5px);
}
circle:nth-child(2) {
stroke-dasharray: 440;
stroke-dashoffset: 440;
}
.card:nth-child(1) svg circle:nth-child(2) {
stroke-dashoffset: calc(440 - (440 * 90) / 100);
stroke: #00ff43;
}
.card:nth-child(2) svg circle:nth-child(2) {
stroke-dashoffset: calc(440 - (440 * 85) / 100);
stroke: #00a1ff;
}
.card:nth-child(3) svg circle:nth-child(2) {
stroke-dashoffset: calc(440 - (440 * 60) / 100);
stroke: #c104ff;
}
#media only screen and (max-width: 915px) {
/* your css of 1024 px screen size */
.card {
flex: 10% !important;
}
}
How do I make the content shift downwards when on 915px browser width so it looks good on mobile. I've tried flex, change display, change width but nothing works. I don't know if it has to do with any of that but I'd appreciate the help.
You can use the grid layout. First, set the container to display: grid;. After you can set how your grid will be with the grid-template-columns: 1fr; (1fr = one column, 1fr 1fr = 2 column, 1fr 2fr = 2 column, but the right one is bigger... etc). After that, you can add gap: 1rem; to have a gap between you column and row.
The Grid Documentation on W3School
Here is a example:
.body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.container {
display: flex;
justify-content: space-around;
}
.container .card {
margin-left: 20px;
position: relative;
width: 250px;
background: #222;
background: linear-gradient(0deg, #1b1b1b, #222, #1b1b1b);
display: flex;
justify-content: center;
align-items: center;
height: 300px;
border-radius: 4px;
text-align: center;
overflow: hidden;
transition: 0.5s;
}
.container .card:hover {
box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
transform: translateY(-10px);
}
.container .card:before {
content: "";
position: absolute;
top: 0;
left: -50%;
width: 100%;
height: 100%;
background: rgba(255, 255, 255, 0.03);
pointer-events: none;
z-index: 1;
}
.percent {
position: relative;
width: 150px;
height: 150px;
border-radius: 50%;
box-shadow: inset 0 0 50px #000;
background: #222;
z-index: 100;
}
.percent .number {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
border-radius: 50%;
}
.percent .number h2 {
color: #777;
font-weight: 700;
font-size: 40px;
transition: 0.5s;
}
.card:hover .percent .number h2 {
color: #fff;
font-size: 60px;
}
.percent .number h2 span {
font-size: 24px;
color: #777;
}
.text {
color: #777;
margin-top: 20px;
font-weight: 700;
font-size: 18px;
letter-spacing: 1px;
text-transform: uppercase;
transition: 0.5s;
}
.card:hover .text {
color: #fff;
}
svg {
position: relative;
width: 150px;
height: 150px;
z-index: 1000;
}
circle {
width: 100%;
height: 100%;
fill: none;
stroke: #191919;
stroke-width: 10;
stroke-linecap: round;
transform: translate(5px, 5px);
}
circle:nth-child(2) {
stroke-dasharray: 440;
stroke-dashoffset: 440;
}
.card:nth-child(1) svg circle:nth-child(2) {
stroke-dashoffset: calc(440 - (440 * 90) / 100);
stroke: #00ff43;
}
.card:nth-child(2) svg circle:nth-child(2) {
stroke-dashoffset: calc(440 - (440 * 85) / 100);
stroke: #00a1ff;
}
.card:nth-child(3) svg circle:nth-child(2) {
stroke-dashoffset: calc(440 - (440 * 60) / 100);
stroke: #c104ff;
}
#media only screen and (max-width: 915px) {
/* your css of 1024 px screen size */
.card {
flex: 10% !important;
}
.grid-class{
display: grid;
grid-template-columns: 1fr;
gap: 1rem;
}
}
<div class="body">
<div class="container grid-class">
<div class="card">
<div class="box">
<div class="percent">
<svg>
<circle cx="70" cy="70" r="70"></circle>
<circle cx="70" cy="70" r="70"></circle>
</svg>
<div class="number">
<h2>90<span>%</span></h2>
</div>
</div>
<h2 class="text">Html</h2>
</div>
</div>
<div class="card">
<div class="box">
<div class="percent">
<svg>
<circle cx="70" cy="70" r="70"></circle>
<circle cx="70" cy="70" r="70"></circle>
</svg>
<div class="number">
<h2>85<span>%</span></h2>
</div>
</div>
<h2 class="text">CSS</h2>
</div>
</div>
<div class="card">
<div class="box">
<div class="percent">
<svg>
<circle cx="70" cy="70" r="70"></circle>
<circle cx="70" cy="70" r="70"></circle>
</svg>
<div class="number">
<h2>60<span>%</span></h2>
</div>
</div>
<h2 class="text">Javascript</h2>
</div>
</div>
</div>
</div>

Match size and scale of fullsize image to SVG viewbox

I have a list of team members. Each member element consists of an image cropped in a circle inside white box. When you hover on the box, the image changes to fullsize. It was inspired by this website:
I achieve this same animation with SVGs. However, in the website above, each image is exactly 300X350 - the same size as the white container box. This creates a flawless transition from masked image to fullsize image - nothing appears to jump or move. On the other hand, my images are a variety of sizes. As a result, the visible portion of the SVG is either zoomed in or out the image, and when you hover, the full image appears to jump:
How can I get the scale and size of fullsize image to match that in the SVG view box, such that it doesn't appear to move?
JSFiddle: http://jsfiddle.net/mzechar/afnxkt2h/2/
html:
<li>
<a href="#">
<article>
<div>
<!-- The masked image -->
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 100 100">
<defs>
<clipPath id="circle">
<circle cx="50" cy="50" r="35"/>
</clipPath>
</defs>
<image width="100%" height="100%" preserveAspectRatio="xMinYMin slice" xlink:href="team/finishedBW/CCK.jpg__.jpg" clip-path="url(#circle)"/>
</svg>
</div>
<!-- The full revealed image -->
<img class="img-full" src="team/finishedBW/CCK.jpg__.jpg" alt="">
<!-- The circle ring -->
<svg viewBox="0 0 100 100" class="circle-ring">
<circle cx="50" cy="50" r="35" stroke="white" stroke-width=".5" fill="transparent" />
</svg>
<div class="bio">
<h2>Chun-Kang Chen</h2>
<h4>Article Subtitle</h4>
</div>
</article>
</a>
</li>
<li>
CSS:
.team-listing{
position:relative;
margin-top:40px;
margin-right:auto;
margin-left:auto;
}
.team-listing li{
display:inline-block;
overflow: hidden;
float:left;
height: 340px;
list-style-position:inside;
margin: 1px 1px 1px 1px;
background-color:#fff;
}
.team-listing ul{
display: flex;
flex-wrap: wrap;
justify-content: center;
flex-direction: row;
flex-flow: row wrap;
flex-shrink: 1;
flex-grow: 1;
float: left;
min-width: 0;
max-width: 100%;
position: relative;
filter: drop-shadow(5px 5px 5px rgba(2,2,22,0.1));
}
a {
display: inline-block;
}
article {
position: relative;
width: 300px;
height: 350px;
/* prevent scaled circle ring from triggering hover */
overflow: hidden;
}
/* create the colour overlay */
article:after {
content: '';
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
display: none;
background: rgba(0, 255, 255, .2);
z-index: 3;
}
/* place full image above SVG */
.img-full {
position: absolute;
top: 0;
right:0;
z-index: 2;
/* hide the full image initially */
display: none;
}
.circle-ring {
position: absolute;
top: 0;
z-index: 3;
/* initially hidden with opacity so it can be animated */
opacity: 0;
transform-origin: 50% 50%;
transform: scale(1.8);
transition: transform .3s ease, opacity .4s ease;
}
a:hover .img-full,
a:hover article:after {
position:absolute;
display: block;
}
a:hover .circle-ring {
opacity: 1;
transform: scale(1);
}
.bio {
position: absolute;
bottom: 0;
padding: 1rem 2rem;
color: #000;
/* keep text above SVG, full image and overlay */
z-index: 4;
}
a:hover .bio {
color: #FFF;
}
/* general */
h2,
h4 {
margin: 0;
font-family: sans-serif;
}
h4 {
font-weight: 300;
}
Have confidence in SVG content. There is no need to define two <svg> elements and a HTML <img> inbetween. Just position the image in an <image> tag inside one <svg> parent, and set/remove the clip path depending on hover state.
The clip path itself remains in a separate, but hidden <svg> so it can be reused for multiple images.
If both the image dimensions and their position so they show the right clipped content differ, it is probably better not to depend on preserveAspectRatio, but to set them absolutely. (Setting overflow:hidden on the <svg> element is more of a precaution, since the spec has changed a bit whether that is the default.)
a {
display: inline-block;
}
article {
position: relative;
width: 300px;
height: 350px;
overflow: hidden;
}
article::after {
content: '';
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
display: none;
background: rgba(0, 255, 255, .2);
z-index: 3;
}
.portrait {
position: relative;
width: 300px;
height: 300px;
overflow: hidden;
}
.portrait image {
clip-path: url(#circle);
}
a:hover .portrait image {
clip-path: none;
}
a:hover article:after {
position: absolute;
display: block;
}
.ring {
fill: none;
stroke: white;
stroke-width: 1;
opacity: 0;
transform-origin: 50% 50%;
transform: scale(1.8);
transition: transform .3s ease, opacity .4s ease;
}
a:hover .ring {
opacity: 1;
transform: scale(1);
}
.bio {
position: absolute;
bottom: 0;
padding: 1rem 2rem;
color: #000;
}
h2 {
font-size: 1.5em;
font-weight: bold;
}
h4 {
font-weight: 300;
}
h2, h4 {
margin: 0;
font-family: sans-serif;
}
<svg width="0" height="0">
<clipPath id="circle">
<circle cx="150" cy="150" r="100"/>
</clipPath>
</svg>
<a href="#">
<article>
<svg class="portrait" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
<!-- no automatic sizing for SVG image, width and height must be set -->
<image width="400" height="300" x="-100" y="0"
xlink:href="http://api.leafsnap.com/v1/team/images/columbia/Neeraj.jpg?h=300"/>
<circle class="ring" cx="150" cy="150" r="100" />
</svg>
<div class="bio">
<h2>Chun-Kang Chen</h2>
<h4>Article Subtitle</h4>
</div>
</article>
</a>
Crop your images, throw out those useless tags and use every image only once.
Hope this helps:
section.team {
margin: auto;
background: #fefefe;
}
.team-listing {
position: relative;
margin: 40px auto 0;
display: flex;
filter: drop-shadow(5px 5px 5px rgba(2, 2, 22, 0.1));
}
.team-listing li {
overflow: hidden;
height: 350px;
list-style: none;
margin: 1px;
background-color: #fff;
}
article {
position: relative;
top: 0;
width: 300px;
height: 300px;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
}
.img-full {
-webkit-clip-path: circle(30% at 50% 50%);
clip-path: circle(30% at 50% 50%);
width: 500px;
}
a:hover .img-full {
-webkit-clip-path: none;
clip-path: none;
filter: sepia(100%);
}
.circle-ring {
position: absolute;
top: 0;
z-index: 3;
opacity: 0;
transform-origin: 50% 50%;
transform: scale(1.8);
transition: transform 0.3s ease, opacity 0.4s ease;
}
a:hover .circle-ring {
opacity: 1;
transform: scale(1);
}
.bio {
position: absolute;
bottom: 0;
margin: 2rem;
color: #000;
}
a:hover .bio > h2 {
color: #fff;
}
h2,
h4 {
margin: 0;
font-family: sans-serif;
}
h4 {
font-weight: 300;
}
<section class="content-wrapper team">
<ul class="team-listing">
<li>
<a href="#">
<article>
<img class="img-full" src="https://i.imgur.com/6eRLJ4I.jpg" alt="">
<svg viewBox="0 0 100 100" class="circle-ring">
<circle cx="50" cy="50" r="35" stroke="white" stroke-width=".5" fill="transparent" />
</svg>
</article>
<div class="bio">
<h2>Article Title</h2>
<h4>Article Subtitle</h4>
</div>
</a>
</li>
<li>
<a href="#">
<article>
<img class="img-full" src="https://i.imgur.com/6eRLJ4I.jpg" alt="">
<svg viewBox="0 0 100 100" class="circle-ring">
<circle cx="50" cy="50" r="35" stroke="white" stroke-width=".5" fill="transparent" />
</svg>
</article>
<div class="bio">
<h2>Article Title</h2>
<h4>Article Subtitle</h4>
</div>
</a>
</li>
</ul>
</section>