Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
SVG tags don't seem sometimes while working with Nodejs

I had a problem with SVG tags not displaying sometimes. I refresh the page, it doesn't seem; I refresh two more times, it seems; I refresh again and it doesn't seem again. I had a little research and I've got that I need to add defer attribute to the script tag. (So, I think it was a problem that originated from the script's being executed before the page fully loaded.)

Now I add the NodeJs to the project and I've started to get this problem again. I've tried to send the HTML file by both app.get() method (express) and fs module, both don't work. How can I fix this problem?

My NodeJs code:

var http = require('http')
var express = require("express")
var app = express()

app.use(express.static(__dirname + '/public'));

app.get("/",(req,res)=>{
    res.sendFile(__dirname+"/index.html")
})

var port = 3000;
app.listen(port,() => {
    console.log(`The server is initialized on port ${port}.`)
})

The part of the code I use SVG (I use them as a border)

<button data-title="Add">
       <svg xmlns="http://www.w3.org/2000/svg">
            <rect pathLength="305"></rect>
       </svg>
</button>

The CSS part (CSSs are in another file)

button {
            padding: 24px 0;
            font-size: 1em;
            font-family: 'Open Sans', sans-serif !important;
            color:rgba(255,255,255,0.7);
            border:none;
            position: relative;
            outline: none;
            background: none;
            cursor: pointer;
            transition: 0.4s;

            &::after {
                content: attr(data-title);
                position: absolute; top:0; left: 0;
                width: 100%; height: 100%;
                display: flex;
                justify-content: center; align-items: center;
                transition: 0.4s;
            }

            &:hover::after {
                text-shadow: 0 0 4px hsla(0, 0%, 100%, 0.4);
            }

            &:hover svg rect {
                fill: rgba(255,255,255,0.1);
            }

            svg, svg rect {
                position: absolute;
                width: 100%; height: 100%;
                top:0;left: 0;
                fill: transparent;
                overflow: initial;
            }

            svg rect {
                stroke: #fff;
                stroke-width: 1;
                stroke-dasharray: 2 4;
                stroke-linecap: butt;
                stroke-opacity: 0.8;
                rx: 25;
                transition: 0.2s;
            }
        }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I would recommend the MDN SVG Tutorial for more information on using the <rect/> element; it's such a wonderful resource: https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Basic_Shapes

Below is a snippet of HTML using the <rect/> svg element:

File: index.html

<html>
<body>
<svg xmlns="http://www.w3.org/2000/svg">
    <rect x="10" y="10" width="100" height="100"/>
</svg>
</body>
</html>

I believe the problem you are seeing is that you have not specified the height and width of the rectangle so nothing is rendered. I am also unfamiliar with the pathLength attribute, but you may not need it.

Please let me know if this helps a bit ^^

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!