📜⬆️⬇️

How to avoid blur SVG-shape?

How to avoid blurring svg-shape with a percentagemargin? Here is the code:

HTML:

<div class="a"> <svg width="9" height="20"> <path fill="#000000" d="M4,1h1v17H4V1z" /> </svg> </div>

CSS:

.a { margin-left: 9%; }

https://jsfiddle.net/evyf0b3e/

Interestmarginsetting is needed for the proper functioning of the site.

htmlcsssvg
nup
nupnup
91177 silver marks1818 bronze marks
  • And what kind of blur?I have all the rules-korytoff
  • @korytoff most likely means svg rendering in firefox.In webkits everything will be ok-alenkins
  • Yes, in other browsers did not check, it is in Firefox.This is due to the fractional offset of the main block when `margin-left: 9% 'falls, for example, at 397.5px.So far, I'm flying round offsets in JS, but if there is a better solution, I will be glad to know about it.-nup
|

2 answers2

I found another solution - disable shape smoothing by theshape-renderingproperty. The code will look like this:

<div class = "a"> <svg width="9" height="20"> <path fill="#000000" shape-rendering="crispEdges" d="M4,1h1v17H4V1z" /> </svg> </div>

https://jsfiddle.net/evyf0b3e/2/

nupnup
91177 silver marks1818 bronze marks
    |

    Try this:

    <div class = "a"> <svg width="5" height="17" viewBox="0 0 5 17"> <path fill="#000000" d="M4,1h1v17H4V1z" /> </svg> </div>

    https://jsfiddle.net/d5an2hmL/

    alenkinsalenkins
    3.07311 golden mark1010 silver marks2424 bronze marks
    • As I understand it, the difference is only inviewBox="0 0 5 17"and resized?This "solves" the problem only in the particular case, and, nevertheless, on even values ​​of themargin-leftimage is slightly blurred.viewBoxitself will not solve the problem of non-integer coordinates.-nup
    • The difference in the size of the viewing area.If you limit the area strictly to the size of the figure, then the blur around the edges can be removed as much as possible for shapes whose contour coincides with the viewing borders:jsfiddle.net/d5an2hmL/1-alenkins
    |
    default


    Source:https://ru.stackoverflow.com/questions/485391/

    More articles:

    • OOP php work with classes
    • Competent protection against SQL-Injection
    • IOS simulator does not work in xcode
    • How do you have a domain set up a reliable send mail through a third-party smtp server?
    • How to get email from a page with javascript
    • How to combine data output with false and if empty?
    • Why is the result of the example not displayed by the last action?
    • Problem with rxtx
    • Denied access by C # path [closed]
    • Compiler 2001/1120 error creating class in C ++

    All Articles