zooming out of SVG using CSS The Next CEO of Stack OverflowStrange out of memory issue while loading an image to a Bitmap objectWhen to use IMG vs. CSS background-image?Convert an image to grayscale in HTML/CSSWhat are the different usecases of PNG vs. GIF vs. JPEG vs. SVG?Disable Auto Zoom in Input “Text” tag - Safari on iPhoneDo I use <img>, <object>, or <embed> for SVG files?HTML5 Canvas vs. SVG vs. divInline SVG in CSSHow to change color of SVG image using CSS (jQuery SVG image replacement)?img src SVG changing the fill color

What is the value of α and β in a triangle?

Why does standard notation not preserve intervals (visually)

Recycling old answers

Can a Bladesinger Wizard use Bladesong with a Hand Crossbow?

Why the difference in type-inference over the as-pattern in two similar function definitions?

Why is my new battery behaving weirdly?

How did people program for Consoles with multiple CPUs?

Example of a Mathematician/Physicist whose Other Publications during their PhD eclipsed their PhD Thesis

How to place nodes around a circle from some initial angle?

Why isn't acceleration always zero whenever velocity is zero, such as the moment a ball bounces off a wall?

Does increasing your ability score affect your main stat?

Why this way of making earth uninhabitable in Interstellar?

What does "Its cash flow is deeply negative" mean?

Method for adding error messages to a dictionary given a key

"misplaced omit" error when >centering columns

If Nick Fury and Coulson already knew about aliens (Kree and Skrull) why did they wait until Thor's appearance to start making weapons?

Is it possible to replace duplicates of a character with one character using tr

Is it my responsibility to learn a new technology in my own time my employer wants to implement?

Why didn't Khan get resurrected in the Genesis Explosion?

Newlines in BSD sed vs gsed

I believe this to be a fraud - hired, then asked to cash check and send cash as Bitcoin

How do I align (1) and (2)?

Why did CATV standarize in 75 ohms and everyone else in 50?

Is it convenient to ask the journal's editor for two additional days to complete a review?



zooming out of SVG using CSS



The Next CEO of Stack OverflowStrange out of memory issue while loading an image to a Bitmap objectWhen to use IMG vs. CSS background-image?Convert an image to grayscale in HTML/CSSWhat are the different usecases of PNG vs. GIF vs. JPEG vs. SVG?Disable Auto Zoom in Input “Text” tag - Safari on iPhoneDo I use <img>, <object>, or <embed> for SVG files?HTML5 Canvas vs. SVG vs. divInline SVG in CSSHow to change color of SVG image using CSS (jQuery SVG image replacement)?img src SVG changing the fill color










0















I have this SVG of a paperplane, which I want to have inside of a circle.
However, when I do the following the SVG is cropped at the edges. The nature of SVG is being scaleable, I have tried fiddling with the properties of the SVG however the problem remains. What should I do to keep this SVG



<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 18.7 14.3" style="enable-background:new 0 0 18.7 14.3;" xml:space="preserve">
<style type="text/css">
.st0fill:#000;
</style>
<path class="st0" d="M18.7,0L0.3,4.1l3,3.6L0,9.4l0.5,4.9l5.6-4.1l2.3,1.5L18.7,0z M1.3,4.4L16,1.2L3.8,7.4L1.3,4.4z M10.3,4.7
l-9.3,5.5l-0.2,1.7L0.6,9.7L10.3,4.7z M1.2,13.2l0.4-2.7l2.6-1.6l1.5,1L1.2,13.2z M4.7,8.6l12-7.1l-8.3,9.5L4.7,8.6z"/>
</svg>


This is my HTML and CSS




 .choice 
background-color: #E0D6AF;
border-radius: 50%;
height: 200px;
width: 200px;
margin: 10px auto;
transition: transform 0.2s;
transform: scale(1);
z-index: 10;

 <img id="paper" class="choice" value="paper" src="http://www.jerrylow.com/demo/rps/paper.svg" alt="a piece of paper"> </img>





Full CSS file



 .container 
display: inline-grid;
padding-top:30px;
grid-gap: 2px;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: 1fr 1fr 1fr;


#submit
border-radius: 50%;
height: 150px;
width: 150px;
margin: auto;
grid-column: 2;
grid-row: 2;
background-color:#E0D6AF;

#submit:hover
transform: scale(1.3);

.choice
background-color: #E0D6AF;
border-radius: 50%;
height: 200px;
width: 200px;
margin: 10px auto;
transition: transform 0.2s;
transform: scale(1);
z-index: 10;

.choice > img:hover
transform: scale(1.1);

#rock
grid-column: 1;
grid-row:1;

#paper
grid-column: 1;
grid-row:2;

#scissor
grid-column: 1;
grid-row:3;


#humanScore > p
padding-top: 80px;
text-align: center !important;

#humanScore
grid-column: 2;
grid-row: 3;

#computerScore > p
padding-top: 80px;
text-align: center !important;

#computerScore
grid-column: 2;
grid-row: 1;


#result
margin: auto;
width: 150px;
height: 150px;
border-radius: 50%;
grid-column: 3;
grid-row: 2;


@keyframes pulse
0%
transform: scale(0);

100%
transform: scale(1);



.resultWin
background-color:lightgreen;
transition: transform 0.2s;
transform: scale(1.3);
animation-name: pulse;
animation-duration: 1s;
animation-iteration-count: 1;
animation-fill-mode: both;


.resultLoss
background-color: crimson;
transition: transform 0.2s;
transform: scale(1.3);
animation-name: pulse;
animation-duration: 1s;
animation-iteration-count: 1;
animation-fill-mode: both;


.resultTie
background-color:goldenrod;
transition: transform 0.2s;
transform: scale(1.3);
animation-name: pulse;
animation-duration: 1s;
animation-iteration-count: 1;
animation-fill-mode: both;

.chosen filter: brightness(70%)


Full react file - needs a ton of refactoring so difficult to read.



import React from 'react';
import './Game.css'

class Game extends React.Component
constructor(props)
super(props);
this.state =
picked: '',
score:
player: 0,
computer: 0
,
previousPicks:
rock: 0,
scissor: 0,
paper: 0
,
result: result: "", player: "", computer: ""
;


unmarkImage = () =>
if (this.state.picked !== "")
document.querySelector(`#$this.state.picked`).classList.remove("chosen")



onClickHandler = (event) =>
this.unmarkImage();
document.querySelector(`#$event.target.attributes.value.value`).classList.add("chosen");
this.setState( picked: event.target.attributes.value.value );


onSubmit = () =>
if (this.state.picked === "")
alert("pick your weapon, before fighting")
return

const self = this;
fetch(`/api/play/$this.state.picked`)
.then(function (res)
res.text().then((function (text)
self.setState( result: JSON.parse('' + text.replace(/(w+):(w+)/g, `"$1":"$2"`) + '') )
self.updateScore(self.state.result.result);
self.updateResult();
self.unmarkImage();
self.updateComputerChoice();
self.updatePreviousPicks(self.state.picked)
self.setState( picked: "" )
))
)


updateScore = (result) =>
let scoreClone = ...this.state.score
if (result === "win")
scoreClone.player++
this.setState(
score: scoreClone
)
else if (result === "loss")
scoreClone.computer++
this.setState(
score: scoreClone
)


updatePreviousPicks = (pick) =>
let previousPicksClone = ...this.state.previousPicks
if (pick === "rock")
previousPicksClone.rock++;
this.setState(
previousPicks: previousPicksClone
)
else if (pick === "scissor")
previousPicksClone.scissor++;
this.setState(
previousPicks: previousPicksClone
)
else
previousPicksClone.paper++;
this.setState(
previousPicks: previousPicksClone
)



onReset = () => //looks clumsy, but good performance
let computerDiv = document.querySelector("#computer")
while (computerDiv.firstChild)
computerDiv.removeChild(computerDiv.firstChild);



updateResult = () =>
let result = document.querySelector("#result")
if (this.state.result.result === "win")
result.classList.add("resultWin");

else if (this.state.result.result === "loss")
result.classList.add("resultLoss");
else
result.classList.add("resultTie");



updateComputerChoice = () =>
let computerChoice = this.state.result.computer;
let result = document.querySelector("#result");
while (result.firstChild)
result.removeChild(result.firstChild);

let answer = document.createElement("img");
let img;
if (computerChoice === "rock")
img = document.getElementById("rock").src;
else if (computerChoice === "scissor")
img = document.getElementById("scissor").src;
else
img = document.getElementById("paper").src;

answer.src = img;
result.appendChild(answer);


render()
return (
<div className="container">
<img id="rock" className="choice" value="rock" src="resources/rock.svg" alt="a rock" onClick=this.onClickHandler></img>
<img id="paper" className="choice" value="paper" src="resources/paper.svg" alt="a piece of paper" onClick=this.onClickHandler></img>
<img id="scissor" className="choice" value="scissor" src="resources/scissor.svg" alt="a scissor" onClick=this.onClickHandler></img>
<button id="submit" className="waves-effect waves-light btn" onClick=this.onSubmit>Fight the AI!</button>
<div id="humanScore">
<p>You: this.state.score.player</p>
</div>
<div id="computerScore">
<p>Computer: this.state.score.computer</p>
</div>
<div id="result" className="">
</div>
</div>
)



export default Game









share|improve this question
























  • This happens because you cut off the corners of the svg with border-radius. I would put the image inside a div .choice with a padding. Also your svg is not a square. Take a look at the viewBox="0 0 18.7 14.3"

    – enxaneta
    Mar 8 at 16:14












  • Doing that would sadly mess up my grid system quite a lot :/

    – Jonas Grønbek
    Mar 8 at 16:26











  • In this case you should share your "grid system" to get some personalised advice

    – enxaneta
    Mar 8 at 16:29











  • I sense some passive aggressiveness, it's alright though - coming up!

    – Jonas Grønbek
    Mar 8 at 16:33











  • And your HTML? Can you please add your HTML.

    – enxaneta
    Mar 8 at 16:36















0















I have this SVG of a paperplane, which I want to have inside of a circle.
However, when I do the following the SVG is cropped at the edges. The nature of SVG is being scaleable, I have tried fiddling with the properties of the SVG however the problem remains. What should I do to keep this SVG



<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 18.7 14.3" style="enable-background:new 0 0 18.7 14.3;" xml:space="preserve">
<style type="text/css">
.st0fill:#000;
</style>
<path class="st0" d="M18.7,0L0.3,4.1l3,3.6L0,9.4l0.5,4.9l5.6-4.1l2.3,1.5L18.7,0z M1.3,4.4L16,1.2L3.8,7.4L1.3,4.4z M10.3,4.7
l-9.3,5.5l-0.2,1.7L0.6,9.7L10.3,4.7z M1.2,13.2l0.4-2.7l2.6-1.6l1.5,1L1.2,13.2z M4.7,8.6l12-7.1l-8.3,9.5L4.7,8.6z"/>
</svg>


This is my HTML and CSS




 .choice 
background-color: #E0D6AF;
border-radius: 50%;
height: 200px;
width: 200px;
margin: 10px auto;
transition: transform 0.2s;
transform: scale(1);
z-index: 10;

 <img id="paper" class="choice" value="paper" src="http://www.jerrylow.com/demo/rps/paper.svg" alt="a piece of paper"> </img>





Full CSS file



 .container 
display: inline-grid;
padding-top:30px;
grid-gap: 2px;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: 1fr 1fr 1fr;


#submit
border-radius: 50%;
height: 150px;
width: 150px;
margin: auto;
grid-column: 2;
grid-row: 2;
background-color:#E0D6AF;

#submit:hover
transform: scale(1.3);

.choice
background-color: #E0D6AF;
border-radius: 50%;
height: 200px;
width: 200px;
margin: 10px auto;
transition: transform 0.2s;
transform: scale(1);
z-index: 10;

.choice > img:hover
transform: scale(1.1);

#rock
grid-column: 1;
grid-row:1;

#paper
grid-column: 1;
grid-row:2;

#scissor
grid-column: 1;
grid-row:3;


#humanScore > p
padding-top: 80px;
text-align: center !important;

#humanScore
grid-column: 2;
grid-row: 3;

#computerScore > p
padding-top: 80px;
text-align: center !important;

#computerScore
grid-column: 2;
grid-row: 1;


#result
margin: auto;
width: 150px;
height: 150px;
border-radius: 50%;
grid-column: 3;
grid-row: 2;


@keyframes pulse
0%
transform: scale(0);

100%
transform: scale(1);



.resultWin
background-color:lightgreen;
transition: transform 0.2s;
transform: scale(1.3);
animation-name: pulse;
animation-duration: 1s;
animation-iteration-count: 1;
animation-fill-mode: both;


.resultLoss
background-color: crimson;
transition: transform 0.2s;
transform: scale(1.3);
animation-name: pulse;
animation-duration: 1s;
animation-iteration-count: 1;
animation-fill-mode: both;


.resultTie
background-color:goldenrod;
transition: transform 0.2s;
transform: scale(1.3);
animation-name: pulse;
animation-duration: 1s;
animation-iteration-count: 1;
animation-fill-mode: both;

.chosen filter: brightness(70%)


Full react file - needs a ton of refactoring so difficult to read.



import React from 'react';
import './Game.css'

class Game extends React.Component
constructor(props)
super(props);
this.state =
picked: '',
score:
player: 0,
computer: 0
,
previousPicks:
rock: 0,
scissor: 0,
paper: 0
,
result: result: "", player: "", computer: ""
;


unmarkImage = () =>
if (this.state.picked !== "")
document.querySelector(`#$this.state.picked`).classList.remove("chosen")



onClickHandler = (event) =>
this.unmarkImage();
document.querySelector(`#$event.target.attributes.value.value`).classList.add("chosen");
this.setState( picked: event.target.attributes.value.value );


onSubmit = () =>
if (this.state.picked === "")
alert("pick your weapon, before fighting")
return

const self = this;
fetch(`/api/play/$this.state.picked`)
.then(function (res)
res.text().then((function (text)
self.setState( result: JSON.parse('' + text.replace(/(w+):(w+)/g, `"$1":"$2"`) + '') )
self.updateScore(self.state.result.result);
self.updateResult();
self.unmarkImage();
self.updateComputerChoice();
self.updatePreviousPicks(self.state.picked)
self.setState( picked: "" )
))
)


updateScore = (result) =>
let scoreClone = ...this.state.score
if (result === "win")
scoreClone.player++
this.setState(
score: scoreClone
)
else if (result === "loss")
scoreClone.computer++
this.setState(
score: scoreClone
)


updatePreviousPicks = (pick) =>
let previousPicksClone = ...this.state.previousPicks
if (pick === "rock")
previousPicksClone.rock++;
this.setState(
previousPicks: previousPicksClone
)
else if (pick === "scissor")
previousPicksClone.scissor++;
this.setState(
previousPicks: previousPicksClone
)
else
previousPicksClone.paper++;
this.setState(
previousPicks: previousPicksClone
)



onReset = () => //looks clumsy, but good performance
let computerDiv = document.querySelector("#computer")
while (computerDiv.firstChild)
computerDiv.removeChild(computerDiv.firstChild);



updateResult = () =>
let result = document.querySelector("#result")
if (this.state.result.result === "win")
result.classList.add("resultWin");

else if (this.state.result.result === "loss")
result.classList.add("resultLoss");
else
result.classList.add("resultTie");



updateComputerChoice = () =>
let computerChoice = this.state.result.computer;
let result = document.querySelector("#result");
while (result.firstChild)
result.removeChild(result.firstChild);

let answer = document.createElement("img");
let img;
if (computerChoice === "rock")
img = document.getElementById("rock").src;
else if (computerChoice === "scissor")
img = document.getElementById("scissor").src;
else
img = document.getElementById("paper").src;

answer.src = img;
result.appendChild(answer);


render()
return (
<div className="container">
<img id="rock" className="choice" value="rock" src="resources/rock.svg" alt="a rock" onClick=this.onClickHandler></img>
<img id="paper" className="choice" value="paper" src="resources/paper.svg" alt="a piece of paper" onClick=this.onClickHandler></img>
<img id="scissor" className="choice" value="scissor" src="resources/scissor.svg" alt="a scissor" onClick=this.onClickHandler></img>
<button id="submit" className="waves-effect waves-light btn" onClick=this.onSubmit>Fight the AI!</button>
<div id="humanScore">
<p>You: this.state.score.player</p>
</div>
<div id="computerScore">
<p>Computer: this.state.score.computer</p>
</div>
<div id="result" className="">
</div>
</div>
)



export default Game









share|improve this question
























  • This happens because you cut off the corners of the svg with border-radius. I would put the image inside a div .choice with a padding. Also your svg is not a square. Take a look at the viewBox="0 0 18.7 14.3"

    – enxaneta
    Mar 8 at 16:14












  • Doing that would sadly mess up my grid system quite a lot :/

    – Jonas Grønbek
    Mar 8 at 16:26











  • In this case you should share your "grid system" to get some personalised advice

    – enxaneta
    Mar 8 at 16:29











  • I sense some passive aggressiveness, it's alright though - coming up!

    – Jonas Grønbek
    Mar 8 at 16:33











  • And your HTML? Can you please add your HTML.

    – enxaneta
    Mar 8 at 16:36













0












0








0








I have this SVG of a paperplane, which I want to have inside of a circle.
However, when I do the following the SVG is cropped at the edges. The nature of SVG is being scaleable, I have tried fiddling with the properties of the SVG however the problem remains. What should I do to keep this SVG



<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 18.7 14.3" style="enable-background:new 0 0 18.7 14.3;" xml:space="preserve">
<style type="text/css">
.st0fill:#000;
</style>
<path class="st0" d="M18.7,0L0.3,4.1l3,3.6L0,9.4l0.5,4.9l5.6-4.1l2.3,1.5L18.7,0z M1.3,4.4L16,1.2L3.8,7.4L1.3,4.4z M10.3,4.7
l-9.3,5.5l-0.2,1.7L0.6,9.7L10.3,4.7z M1.2,13.2l0.4-2.7l2.6-1.6l1.5,1L1.2,13.2z M4.7,8.6l12-7.1l-8.3,9.5L4.7,8.6z"/>
</svg>


This is my HTML and CSS




 .choice 
background-color: #E0D6AF;
border-radius: 50%;
height: 200px;
width: 200px;
margin: 10px auto;
transition: transform 0.2s;
transform: scale(1);
z-index: 10;

 <img id="paper" class="choice" value="paper" src="http://www.jerrylow.com/demo/rps/paper.svg" alt="a piece of paper"> </img>





Full CSS file



 .container 
display: inline-grid;
padding-top:30px;
grid-gap: 2px;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: 1fr 1fr 1fr;


#submit
border-radius: 50%;
height: 150px;
width: 150px;
margin: auto;
grid-column: 2;
grid-row: 2;
background-color:#E0D6AF;

#submit:hover
transform: scale(1.3);

.choice
background-color: #E0D6AF;
border-radius: 50%;
height: 200px;
width: 200px;
margin: 10px auto;
transition: transform 0.2s;
transform: scale(1);
z-index: 10;

.choice > img:hover
transform: scale(1.1);

#rock
grid-column: 1;
grid-row:1;

#paper
grid-column: 1;
grid-row:2;

#scissor
grid-column: 1;
grid-row:3;


#humanScore > p
padding-top: 80px;
text-align: center !important;

#humanScore
grid-column: 2;
grid-row: 3;

#computerScore > p
padding-top: 80px;
text-align: center !important;

#computerScore
grid-column: 2;
grid-row: 1;


#result
margin: auto;
width: 150px;
height: 150px;
border-radius: 50%;
grid-column: 3;
grid-row: 2;


@keyframes pulse
0%
transform: scale(0);

100%
transform: scale(1);



.resultWin
background-color:lightgreen;
transition: transform 0.2s;
transform: scale(1.3);
animation-name: pulse;
animation-duration: 1s;
animation-iteration-count: 1;
animation-fill-mode: both;


.resultLoss
background-color: crimson;
transition: transform 0.2s;
transform: scale(1.3);
animation-name: pulse;
animation-duration: 1s;
animation-iteration-count: 1;
animation-fill-mode: both;


.resultTie
background-color:goldenrod;
transition: transform 0.2s;
transform: scale(1.3);
animation-name: pulse;
animation-duration: 1s;
animation-iteration-count: 1;
animation-fill-mode: both;

.chosen filter: brightness(70%)


Full react file - needs a ton of refactoring so difficult to read.



import React from 'react';
import './Game.css'

class Game extends React.Component
constructor(props)
super(props);
this.state =
picked: '',
score:
player: 0,
computer: 0
,
previousPicks:
rock: 0,
scissor: 0,
paper: 0
,
result: result: "", player: "", computer: ""
;


unmarkImage = () =>
if (this.state.picked !== "")
document.querySelector(`#$this.state.picked`).classList.remove("chosen")



onClickHandler = (event) =>
this.unmarkImage();
document.querySelector(`#$event.target.attributes.value.value`).classList.add("chosen");
this.setState( picked: event.target.attributes.value.value );


onSubmit = () =>
if (this.state.picked === "")
alert("pick your weapon, before fighting")
return

const self = this;
fetch(`/api/play/$this.state.picked`)
.then(function (res)
res.text().then((function (text)
self.setState( result: JSON.parse('' + text.replace(/(w+):(w+)/g, `"$1":"$2"`) + '') )
self.updateScore(self.state.result.result);
self.updateResult();
self.unmarkImage();
self.updateComputerChoice();
self.updatePreviousPicks(self.state.picked)
self.setState( picked: "" )
))
)


updateScore = (result) =>
let scoreClone = ...this.state.score
if (result === "win")
scoreClone.player++
this.setState(
score: scoreClone
)
else if (result === "loss")
scoreClone.computer++
this.setState(
score: scoreClone
)


updatePreviousPicks = (pick) =>
let previousPicksClone = ...this.state.previousPicks
if (pick === "rock")
previousPicksClone.rock++;
this.setState(
previousPicks: previousPicksClone
)
else if (pick === "scissor")
previousPicksClone.scissor++;
this.setState(
previousPicks: previousPicksClone
)
else
previousPicksClone.paper++;
this.setState(
previousPicks: previousPicksClone
)



onReset = () => //looks clumsy, but good performance
let computerDiv = document.querySelector("#computer")
while (computerDiv.firstChild)
computerDiv.removeChild(computerDiv.firstChild);



updateResult = () =>
let result = document.querySelector("#result")
if (this.state.result.result === "win")
result.classList.add("resultWin");

else if (this.state.result.result === "loss")
result.classList.add("resultLoss");
else
result.classList.add("resultTie");



updateComputerChoice = () =>
let computerChoice = this.state.result.computer;
let result = document.querySelector("#result");
while (result.firstChild)
result.removeChild(result.firstChild);

let answer = document.createElement("img");
let img;
if (computerChoice === "rock")
img = document.getElementById("rock").src;
else if (computerChoice === "scissor")
img = document.getElementById("scissor").src;
else
img = document.getElementById("paper").src;

answer.src = img;
result.appendChild(answer);


render()
return (
<div className="container">
<img id="rock" className="choice" value="rock" src="resources/rock.svg" alt="a rock" onClick=this.onClickHandler></img>
<img id="paper" className="choice" value="paper" src="resources/paper.svg" alt="a piece of paper" onClick=this.onClickHandler></img>
<img id="scissor" className="choice" value="scissor" src="resources/scissor.svg" alt="a scissor" onClick=this.onClickHandler></img>
<button id="submit" className="waves-effect waves-light btn" onClick=this.onSubmit>Fight the AI!</button>
<div id="humanScore">
<p>You: this.state.score.player</p>
</div>
<div id="computerScore">
<p>Computer: this.state.score.computer</p>
</div>
<div id="result" className="">
</div>
</div>
)



export default Game









share|improve this question
















I have this SVG of a paperplane, which I want to have inside of a circle.
However, when I do the following the SVG is cropped at the edges. The nature of SVG is being scaleable, I have tried fiddling with the properties of the SVG however the problem remains. What should I do to keep this SVG



<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 18.7 14.3" style="enable-background:new 0 0 18.7 14.3;" xml:space="preserve">
<style type="text/css">
.st0fill:#000;
</style>
<path class="st0" d="M18.7,0L0.3,4.1l3,3.6L0,9.4l0.5,4.9l5.6-4.1l2.3,1.5L18.7,0z M1.3,4.4L16,1.2L3.8,7.4L1.3,4.4z M10.3,4.7
l-9.3,5.5l-0.2,1.7L0.6,9.7L10.3,4.7z M1.2,13.2l0.4-2.7l2.6-1.6l1.5,1L1.2,13.2z M4.7,8.6l12-7.1l-8.3,9.5L4.7,8.6z"/>
</svg>


This is my HTML and CSS




 .choice 
background-color: #E0D6AF;
border-radius: 50%;
height: 200px;
width: 200px;
margin: 10px auto;
transition: transform 0.2s;
transform: scale(1);
z-index: 10;

 <img id="paper" class="choice" value="paper" src="http://www.jerrylow.com/demo/rps/paper.svg" alt="a piece of paper"> </img>





Full CSS file



 .container 
display: inline-grid;
padding-top:30px;
grid-gap: 2px;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: 1fr 1fr 1fr;


#submit
border-radius: 50%;
height: 150px;
width: 150px;
margin: auto;
grid-column: 2;
grid-row: 2;
background-color:#E0D6AF;

#submit:hover
transform: scale(1.3);

.choice
background-color: #E0D6AF;
border-radius: 50%;
height: 200px;
width: 200px;
margin: 10px auto;
transition: transform 0.2s;
transform: scale(1);
z-index: 10;

.choice > img:hover
transform: scale(1.1);

#rock
grid-column: 1;
grid-row:1;

#paper
grid-column: 1;
grid-row:2;

#scissor
grid-column: 1;
grid-row:3;


#humanScore > p
padding-top: 80px;
text-align: center !important;

#humanScore
grid-column: 2;
grid-row: 3;

#computerScore > p
padding-top: 80px;
text-align: center !important;

#computerScore
grid-column: 2;
grid-row: 1;


#result
margin: auto;
width: 150px;
height: 150px;
border-radius: 50%;
grid-column: 3;
grid-row: 2;


@keyframes pulse
0%
transform: scale(0);

100%
transform: scale(1);



.resultWin
background-color:lightgreen;
transition: transform 0.2s;
transform: scale(1.3);
animation-name: pulse;
animation-duration: 1s;
animation-iteration-count: 1;
animation-fill-mode: both;


.resultLoss
background-color: crimson;
transition: transform 0.2s;
transform: scale(1.3);
animation-name: pulse;
animation-duration: 1s;
animation-iteration-count: 1;
animation-fill-mode: both;


.resultTie
background-color:goldenrod;
transition: transform 0.2s;
transform: scale(1.3);
animation-name: pulse;
animation-duration: 1s;
animation-iteration-count: 1;
animation-fill-mode: both;

.chosen filter: brightness(70%)


Full react file - needs a ton of refactoring so difficult to read.



import React from 'react';
import './Game.css'

class Game extends React.Component
constructor(props)
super(props);
this.state =
picked: '',
score:
player: 0,
computer: 0
,
previousPicks:
rock: 0,
scissor: 0,
paper: 0
,
result: result: "", player: "", computer: ""
;


unmarkImage = () =>
if (this.state.picked !== "")
document.querySelector(`#$this.state.picked`).classList.remove("chosen")



onClickHandler = (event) =>
this.unmarkImage();
document.querySelector(`#$event.target.attributes.value.value`).classList.add("chosen");
this.setState( picked: event.target.attributes.value.value );


onSubmit = () =>
if (this.state.picked === "")
alert("pick your weapon, before fighting")
return

const self = this;
fetch(`/api/play/$this.state.picked`)
.then(function (res)
res.text().then((function (text)
self.setState( result: JSON.parse('' + text.replace(/(w+):(w+)/g, `"$1":"$2"`) + '') )
self.updateScore(self.state.result.result);
self.updateResult();
self.unmarkImage();
self.updateComputerChoice();
self.updatePreviousPicks(self.state.picked)
self.setState( picked: "" )
))
)


updateScore = (result) =>
let scoreClone = ...this.state.score
if (result === "win")
scoreClone.player++
this.setState(
score: scoreClone
)
else if (result === "loss")
scoreClone.computer++
this.setState(
score: scoreClone
)


updatePreviousPicks = (pick) =>
let previousPicksClone = ...this.state.previousPicks
if (pick === "rock")
previousPicksClone.rock++;
this.setState(
previousPicks: previousPicksClone
)
else if (pick === "scissor")
previousPicksClone.scissor++;
this.setState(
previousPicks: previousPicksClone
)
else
previousPicksClone.paper++;
this.setState(
previousPicks: previousPicksClone
)



onReset = () => //looks clumsy, but good performance
let computerDiv = document.querySelector("#computer")
while (computerDiv.firstChild)
computerDiv.removeChild(computerDiv.firstChild);



updateResult = () =>
let result = document.querySelector("#result")
if (this.state.result.result === "win")
result.classList.add("resultWin");

else if (this.state.result.result === "loss")
result.classList.add("resultLoss");
else
result.classList.add("resultTie");



updateComputerChoice = () =>
let computerChoice = this.state.result.computer;
let result = document.querySelector("#result");
while (result.firstChild)
result.removeChild(result.firstChild);

let answer = document.createElement("img");
let img;
if (computerChoice === "rock")
img = document.getElementById("rock").src;
else if (computerChoice === "scissor")
img = document.getElementById("scissor").src;
else
img = document.getElementById("paper").src;

answer.src = img;
result.appendChild(answer);


render()
return (
<div className="container">
<img id="rock" className="choice" value="rock" src="resources/rock.svg" alt="a rock" onClick=this.onClickHandler></img>
<img id="paper" className="choice" value="paper" src="resources/paper.svg" alt="a piece of paper" onClick=this.onClickHandler></img>
<img id="scissor" className="choice" value="scissor" src="resources/scissor.svg" alt="a scissor" onClick=this.onClickHandler></img>
<button id="submit" className="waves-effect waves-light btn" onClick=this.onSubmit>Fight the AI!</button>
<div id="humanScore">
<p>You: this.state.score.player</p>
</div>
<div id="computerScore">
<p>Computer: this.state.score.computer</p>
</div>
<div id="result" className="">
</div>
</div>
)



export default Game





 .choice 
background-color: #E0D6AF;
border-radius: 50%;
height: 200px;
width: 200px;
margin: 10px auto;
transition: transform 0.2s;
transform: scale(1);
z-index: 10;

 <img id="paper" class="choice" value="paper" src="http://www.jerrylow.com/demo/rps/paper.svg" alt="a piece of paper"> </img>





 .choice 
background-color: #E0D6AF;
border-radius: 50%;
height: 200px;
width: 200px;
margin: 10px auto;
transition: transform 0.2s;
transform: scale(1);
z-index: 10;

 <img id="paper" class="choice" value="paper" src="http://www.jerrylow.com/demo/rps/paper.svg" alt="a piece of paper"> </img>






image svg zoom scale






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 16:34







Jonas Grønbek

















asked Mar 8 at 15:33









Jonas GrønbekJonas Grønbek

411112




411112












  • This happens because you cut off the corners of the svg with border-radius. I would put the image inside a div .choice with a padding. Also your svg is not a square. Take a look at the viewBox="0 0 18.7 14.3"

    – enxaneta
    Mar 8 at 16:14












  • Doing that would sadly mess up my grid system quite a lot :/

    – Jonas Grønbek
    Mar 8 at 16:26











  • In this case you should share your "grid system" to get some personalised advice

    – enxaneta
    Mar 8 at 16:29











  • I sense some passive aggressiveness, it's alright though - coming up!

    – Jonas Grønbek
    Mar 8 at 16:33











  • And your HTML? Can you please add your HTML.

    – enxaneta
    Mar 8 at 16:36

















  • This happens because you cut off the corners of the svg with border-radius. I would put the image inside a div .choice with a padding. Also your svg is not a square. Take a look at the viewBox="0 0 18.7 14.3"

    – enxaneta
    Mar 8 at 16:14












  • Doing that would sadly mess up my grid system quite a lot :/

    – Jonas Grønbek
    Mar 8 at 16:26











  • In this case you should share your "grid system" to get some personalised advice

    – enxaneta
    Mar 8 at 16:29











  • I sense some passive aggressiveness, it's alright though - coming up!

    – Jonas Grønbek
    Mar 8 at 16:33











  • And your HTML? Can you please add your HTML.

    – enxaneta
    Mar 8 at 16:36
















This happens because you cut off the corners of the svg with border-radius. I would put the image inside a div .choice with a padding. Also your svg is not a square. Take a look at the viewBox="0 0 18.7 14.3"

– enxaneta
Mar 8 at 16:14






This happens because you cut off the corners of the svg with border-radius. I would put the image inside a div .choice with a padding. Also your svg is not a square. Take a look at the viewBox="0 0 18.7 14.3"

– enxaneta
Mar 8 at 16:14














Doing that would sadly mess up my grid system quite a lot :/

– Jonas Grønbek
Mar 8 at 16:26





Doing that would sadly mess up my grid system quite a lot :/

– Jonas Grønbek
Mar 8 at 16:26













In this case you should share your "grid system" to get some personalised advice

– enxaneta
Mar 8 at 16:29





In this case you should share your "grid system" to get some personalised advice

– enxaneta
Mar 8 at 16:29













I sense some passive aggressiveness, it's alright though - coming up!

– Jonas Grønbek
Mar 8 at 16:33





I sense some passive aggressiveness, it's alright though - coming up!

– Jonas Grønbek
Mar 8 at 16:33













And your HTML? Can you please add your HTML.

– enxaneta
Mar 8 at 16:36





And your HTML? Can you please add your HTML.

– enxaneta
Mar 8 at 16:36












1 Answer
1






active

oldest

votes


















1














To demonstrate @exaneta 's original suggestion, which I can't imagine would have any effect on a grid system, run the snippet below. If that's not what you are trying to accomplish, I'll delete this answer.






.choice 
background-color: #E0D6AF;
border-radius: 50%;
height: 200px;
width: 200px;
margin: 10px auto;
transition: transform 0.2s;
transform: scale(1);
z-index: 10;
display: flex;
justify-content: center;
align-items: center;

.choice > img#paper
width: 60%;

<div class="choice">
<img
id="paper"
value="paper"
src="http://www.jerrylow.com/demo/rps/paper.svg"
alt="a piece of paper"
/>
</div>








share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55066379%2fzooming-out-of-svg-using-css%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    To demonstrate @exaneta 's original suggestion, which I can't imagine would have any effect on a grid system, run the snippet below. If that's not what you are trying to accomplish, I'll delete this answer.






    .choice 
    background-color: #E0D6AF;
    border-radius: 50%;
    height: 200px;
    width: 200px;
    margin: 10px auto;
    transition: transform 0.2s;
    transform: scale(1);
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;

    .choice > img#paper
    width: 60%;

    <div class="choice">
    <img
    id="paper"
    value="paper"
    src="http://www.jerrylow.com/demo/rps/paper.svg"
    alt="a piece of paper"
    />
    </div>








    share|improve this answer



























      1














      To demonstrate @exaneta 's original suggestion, which I can't imagine would have any effect on a grid system, run the snippet below. If that's not what you are trying to accomplish, I'll delete this answer.






      .choice 
      background-color: #E0D6AF;
      border-radius: 50%;
      height: 200px;
      width: 200px;
      margin: 10px auto;
      transition: transform 0.2s;
      transform: scale(1);
      z-index: 10;
      display: flex;
      justify-content: center;
      align-items: center;

      .choice > img#paper
      width: 60%;

      <div class="choice">
      <img
      id="paper"
      value="paper"
      src="http://www.jerrylow.com/demo/rps/paper.svg"
      alt="a piece of paper"
      />
      </div>








      share|improve this answer

























        1












        1








        1







        To demonstrate @exaneta 's original suggestion, which I can't imagine would have any effect on a grid system, run the snippet below. If that's not what you are trying to accomplish, I'll delete this answer.






        .choice 
        background-color: #E0D6AF;
        border-radius: 50%;
        height: 200px;
        width: 200px;
        margin: 10px auto;
        transition: transform 0.2s;
        transform: scale(1);
        z-index: 10;
        display: flex;
        justify-content: center;
        align-items: center;

        .choice > img#paper
        width: 60%;

        <div class="choice">
        <img
        id="paper"
        value="paper"
        src="http://www.jerrylow.com/demo/rps/paper.svg"
        alt="a piece of paper"
        />
        </div>








        share|improve this answer













        To demonstrate @exaneta 's original suggestion, which I can't imagine would have any effect on a grid system, run the snippet below. If that's not what you are trying to accomplish, I'll delete this answer.






        .choice 
        background-color: #E0D6AF;
        border-radius: 50%;
        height: 200px;
        width: 200px;
        margin: 10px auto;
        transition: transform 0.2s;
        transform: scale(1);
        z-index: 10;
        display: flex;
        justify-content: center;
        align-items: center;

        .choice > img#paper
        width: 60%;

        <div class="choice">
        <img
        id="paper"
        value="paper"
        src="http://www.jerrylow.com/demo/rps/paper.svg"
        alt="a piece of paper"
        />
        </div>








        .choice 
        background-color: #E0D6AF;
        border-radius: 50%;
        height: 200px;
        width: 200px;
        margin: 10px auto;
        transition: transform 0.2s;
        transform: scale(1);
        z-index: 10;
        display: flex;
        justify-content: center;
        align-items: center;

        .choice > img#paper
        width: 60%;

        <div class="choice">
        <img
        id="paper"
        value="paper"
        src="http://www.jerrylow.com/demo/rps/paper.svg"
        alt="a piece of paper"
        />
        </div>





        .choice 
        background-color: #E0D6AF;
        border-radius: 50%;
        height: 200px;
        width: 200px;
        margin: 10px auto;
        transition: transform 0.2s;
        transform: scale(1);
        z-index: 10;
        display: flex;
        justify-content: center;
        align-items: center;

        .choice > img#paper
        width: 60%;

        <div class="choice">
        <img
        id="paper"
        value="paper"
        src="http://www.jerrylow.com/demo/rps/paper.svg"
        alt="a piece of paper"
        />
        </div>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 8 at 17:22









        TedTed

        11.5k12146




        11.5k12146





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55066379%2fzooming-out-of-svg-using-css%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to get text form Clipboard with JavaScript in Firefox 56?How to validate an email address in JavaScript?How do JavaScript closures work?How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How do I copy to the clipboard in JavaScript?How do I include a JavaScript file in another JavaScript file?Get the current URL with JavaScript?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?

            Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

            List of MPs elected to the English parliament in 1640 (April) Contents List of constituencies and members See also Notes References Navigation menueNational Archives – The Glynde Place ArchivesCobbett's Parliamentary history of England, from the Norman Conquest in 1066 to the year 1803'Aldermen in Parliament', The Aldermen of the City of London: Temp. Henry III – 1912onepage&q&f&#61, false 229