Create impressive full-screen SVG line designs

I am working towards creating the design depicted in the image linked below: https://i.sstatic.net/QDL11.jpg

The desired effect involves having lines extending infinitely from each circle, rotating endlessly using CSS keyframes. I attempted to achieve this by manipulating numerous divs and rotating them by 10 degrees, but did not accomplish my goal. Therefore, I explored SVG as an alternative solution. However, my SVG implementation did not meet the requirements as the lines did not extend to fill the entire screen. The provided fiddle showcases my attempt.

html,
body {
  overflow: hidden;
}

.fw {
  border-top: 1px red solid;
  width: 2000px;
}

.wrapper {
  overflow: hidden;
}
/* Keyframe animations for rotation */
@-webkit-keyframes rotating
/* Safari and Chrome */

{
  from {
    -webkit-transform: rotate(0deg);
    -o-transform: rotate(0deg);
    transform: rotate(0deg);
  }
  to {
    -webkit-transform: rotate(360deg);
    -o-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}

@keyframes rotating {
  from {
    -ms-transform: rotate(0deg);
    -moz-transform: rotate(0deg);
    -webkit-transform: rotate(0deg);
    -o-transform: rotate(0deg);
    transform: rotate(0deg);
  }
  to {
    -ms-transform: rotate(360deg);
    -moz-transform: rotate(360deg);
    -webkit-transform: rotate(360deg);
    -o-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}
/* Wrapper element for animation */
.wrapper1 {
  display: inline-block;
  position: fixed;
  -webkit-animation: rotating 10s linear infinite;
  -moz-animation: rotating 10s linear infinite;
  -ms-animation: rotating 10s linear infinite;
  -o-animation: rotating 10s linear infinite;
  animation: rotating 10s linear infinite;
}
<div class="wrapper" style="position:absolute;top:20%;left:10%;width:100%;height:100%;">
  <div class="wrapper1">

    <!-- SVG Content Generated from Adobe Illustrator -->
    <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/" x="0px" y="0px" width="100%" height="100%" viewBox="0 0 1097 1097" style="enable-background:new 0 0 1097 1097;"
      xml:space="preserve">
<style type="text/css">
.st0{fill:none;stroke:red;stroke-miterlimit:10;}

</style>
<defs>
</defs>
<g>
<g>
<line class="st0" x1="551.5" y1="0" x2="551.5" y2="1097"/>
</g>
<g>
<line class="st0" x1="1097" y1="555.5" x2="0" y2="555.5"/>
</g>
<g>
<line class="st0" x1="935.6" y1="152.6" x2="179.7" y2="947.6"/>
</g> /* Additional line elements */
...

</svg>
    <div style="position:fixed;top:50%;left:50%;margin:0px auto;display:block;text-align:center;   width: 100px;
    height: 100px;
    background: red;
    -moz-border-radius: 50px;
    -webkit-border-radius: 50px;
    border-radius: 50px;">Support</div>

  </div>

</div>

I would appreciate any guidance or resources you can provide to assist me in achieving the intended outcome. Thank you in advance.

Answer №1

In my design approach, I prioritize the circle as the focal point and introduce a pseudo element filled with multiple lines utilizing rotated SVG backgrounds.

body {
 margin::0;
 overflow:hidden;
}

.circle {
  height:100px;
  width:100px;
  margin:50px;
  background:red;
  border-radius:50%;
  position:relative;
}
.circle:before {
    content:"";
    position:absolute;
    top:-5000%;
    left:-5000%;
    right:-5000%;
    bottom:-5000%;
    background-image:
    url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200" height="5000" width="5000"><line x1="100" y1="0" x2="100" y2="200" stroke="red" stroke-width="0.05" /></svg>'),
    url('data:image/svg+xml,<svg style="transform:rotate(20deg)" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200" height="5000" width="5000"><line x1="100" y1="0" x2="100" y2="200" stroke="red" stroke-width="0.05" /></svg>'),
    url('data:image/svg+xml,<svg style="transform:rotate(40deg)" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200" height="5000" width="5000"><line x1="100" y1="0" x2="100" y2="200" stroke="red" stroke-width="0.05" /></svg>'),
    url('data:image/svg+xml,<svg style="transform:rotate(60deg)" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200" height="5000" width="5000"><line x1="100" y1="0" x2="100" y2="200" stroke="red" stroke-width="0.05" /></svg>'),
    url('data:image/svg+xml,<svg style="transform:rotate(80deg)" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200" height="5000" width="5000"><line x1="100" y1="0" x2="100" y2="200" stroke="red" stroke-width="0.05" /></svg>'),
    url('data:image/svg+xml,<svg style="transform:rotate(100deg)" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200" height="5000" width="5000"><line x1="100" y1="0" x2="100" y2="200" stroke="red" stroke-width="0.05" /></svg>'),
    url('data:image/svg+xml,<svg style="transform:rotate(120deg)" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200" height="5000" width="5000"><line x1="100" y1="0" x2="100" y2="200" stroke="red" stroke-width="0.05" /></svg>'),
    url('data:image/svg+xml,<svg style="transform:rotate(140deg)" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200" height="5000" width="5000"><line x1="100" y1="0" x2="100" y2="200" stroke="red" stroke-width="0.05" /></svg>'),
    url('data:image/svg+xml,<svg style="transform:rotate(160deg)" xmlns="//www.w3.org/2000/svg" viewBox="0 0 200 200" height="5000" width="5000"><line x1="100" y1="0" x2="100" y2="200" stroke="red" stroke-width="0.05"></svg>');
    background-size:100% 100%;
  animation:animate 6s infinite linear;
}

@keyframes animate {
  from {
    transform:rotate(0);
  }
  to {
    transform:rotate(360deg);
  }
}
<div class="circle">

</div>

To simplify the process, leveraging JS can help in generating the background code:

var all = document.querySelectorAll('.circle');

for (var i = 0; i < all.length; i++) {
  var c = all[i].getAttribute("data-color");
  var s = parseInt(all[i].getAttribute("data-step"));
  var b = 'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200" height="5000" width="5000"><line x1="100" y1="0" x2="100" y2="200" stroke="' + c + '" stroke-width="0.05" /></svg>\')';
  var end = 180 / s;
  for (var j = 1; j < end; j++) {
    b += ',url(\'data:image/svg+xml,<svg style="transform:rotate(' + s * j + 'deg)" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200" height="5000" width="5000"><line x1="100" y1="0" x2="100" y2="200" stroke="' + c + '" stroke-width="0.05" /></svg>\')';
  }
  all[i].style.setProperty("--b", b);
  all[i].querySelector('span').style.setProperty("background", c);

}
body {
  overflow: hidden;
}

.circle {
  height: 100px;
  width: 100px;
  position:absolute;
}
.circle span {
  position:relative;
  height:100%;
  width:100%;
  display:flex;
  justify-content:center;
  align-items:center;
  z-index:3;
  border-radius: 50%;
  color:#fff;
}

.circle:after {
  content: "";
  z-index: -1;
  position: absolute;
  top: -5000%;
  left: -5000%;
  right: -5000%;
  bottom: -5000%;
  background-image: var(--b);
  background-size: 100% 100%;
  animation: animate 10s infinite linear;
}

@keyframes animate {
  from {
    transform: rotate(0);
  }
  to {
    transform: rotate(360deg);
  }
}
<!-- step will define the degree between each line -->

<div class="circle" data-color="red" data-step="10">
<span>some text</span>
</div>
<div class="circle" style="top:150px;left:150px;" data-color="green" data-step="20">
<span>text</span>
</div>

<div class="circle" style="left:250px;" data-color="orange" data-step="30">
<span>more here</span>
</div>

<div class="circle" style="right:50px;bottom:50px" data-color="cyan" data-step="10">
<span>more here</span>
</div>

Answer №2

At first, my inspiration stemmed from pondering about pseudo-elements, yet the limitation of only two per element (::before and ::after) made it evident that achieving the desired outcome would not be feasible.

Therefore, albeit reluctantly, resorting to numerous divs became necessary. However, the solution I devised demands the fewest divs (excluding pseudo-elements) and offers flexibility in adjusting the number of lines, spacing between them, or their length with ease.

body,
html {
  height: 100%;
  margin: 0;
}

.wrapper {
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.circle {
  height: 150px;
  width: 150px;
  position: relative;
  border-radius: 50%;
  background-color: red;
  animation: spin 20s linear infinite;
}

.line {
  height: 1500%;
  width: 1px;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  margin: auto;
  background: red;
  z-index: -1;
}

(line styles omitted for brevity)

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
<div class="wrapper">
  <div class="circle">
    <div class="line line1"></div>
    (remaining lines omitted for brevity)
  </div>
</div>

To simplify this task without manually composing each line, I turned to the Text Pastry package in Sublime Text.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Height Difference Caused by Textarea Overflow with Auto Scrollbars

Displayed below is code that generates a textarea with 3 visible rows: <textarea id="txtInput" rows="3" cols="20" style="overflow:auto"></textarea> Unexpectedly, in Firefox (version 20.0.1), the textarea displays 4 rows instead of 3. To view ...

Disabling the Autocomplete Drop-Down Arrow

Can the drop-down arrow icon be removed from the material-ui Autocomplete react component? My current view includes a blue arrow that I'd like to remove, opting instead for text to automatically drop down as I type. https://i.stack.imgur.com/ZTLYu.p ...

Personalized FullCalendar header title

Is there a way to display a unique header title for each calendar in my collection of 16? I've been trying various modifications to the code snippet below with no success: firstDay: <?php echo $iFirstDay; ?>, header: { left: 'prev,next ...

`In NodeJS, facing a challenge with implementing a many-to-many relationship using Sequelize's

I'm in the process of setting up many-to-many relationships between roles and accesses. The `roles` table will contain a list of roles (admin, developer, etc...) and the `accesses` table will have a list of permissions (Create Project, Create Site, De ...

Learn a valuable trick to activate CSS animation using a button - simply click on the button and watch the animation start over each time

I already know how to do this once. However, I would like the animation to restart or begin again when the user clicks on it a second time. Here is what I have: function animation() { document.getElementById('ExampleButton').className = &apo ...

Node's MongoDB client

Currently tackling the challenge of connecting MongoDB in Node.js and passing the link to the client as an outer variable. I am looking to develop a module that can yield the result of the .find() method. How should I proceed with this? const MongoClient ...

What is causing the button within my ExtJS grid to display as "[object Object]"?

Within an ExtJS grid, I am facing a scenario where I need to display a button in a specific column when the content of a cell meets certain criteria. To achieve this, I define the column with the button using a rendering function as shown below: { he ...

Transform ajax functionality into jquery

I need help converting an AJAX function to a jQuery function, but I'm not sure how to do it. function convertToJquery() { // Create our XMLHttpRequest object var hr = new XMLHttpRequest(); // Set up variables needed to send to PHP file var ur ...

Each time forEach is called, it increments the previous result by 1

My service returns a response containing the following data: {"id":157336,"results":[ {"id":"53db3c790e0a26189a000d09","iso_639_1":"en","key":"ePbKGoIGAXY","name":"Trailer 3","site":"YouTube","size":1080,"type":"Trailer"}, {"id":"550df44b925141355 ...

Using javascript, what is the best way to clear a text field with a specific condition?

When I clear the text field #t1, I expect text field #d1 to also clear. However, the last two lines of code do not achieve this result. function utl() { var tField = document.getElementById('t1'); var dField = document.getElementById(&a ...

Executing a for loop with a parameter passed into the setTimeout function

Help Needed with AJAX Request Timeout Issue I recently created an array and tried to send an ajax request using setTimeout. However, I encountered a problem where I couldn't get the parameter in setTimeout. The console log showed that the variable &a ...

I want to learn how to display the rupee symbol instead of the default dollar symbol in AngularJS for specific currency symbols

When using 'currency' in AngularJS, I noticed that a dollar symbol is displayed. How can I change this to show the required currency symbol based on different requirements? Currently, I am looking for information on how to display a rupee symbol ...

What is the best way to reposition an element to the end of its flexbox container?

I have a flexbox-container that contains multiple details-elements with flex-wrap behavior. My goal is to have a details-element move below the other elements within the container when it is opened. For example, I want it to go from this initial layout: ...

JS/TS Strategies for Sharing Code Across Multiple Projects

Perhaps there is a different approach that has not crossed my mind. I have spent some time exploring various methods like js/ts with npm link, git submodules, tsconfig paths, symlink, npm/pnpm/yarn workspace, npm pack & npm link, package.json exports, ...

Troubles with retrieving Array data for a JavaScript column chart

I am currently developing a Flask app in Python and utilizing render_template to send back 2 arrays, "names" and "deals", to my HTML file. I have confirmed that these arrays are working correctly based on the code snippet below that I tested, which display ...

Trigger IntersectionObserver refresh

Can an IntersectionObserver instance be updated or triggered to run manually? By default, the callback is executed when the viewport changes, but I am interested in activating it based on other events such as element changes. For example: During initiali ...

Issue with Intel XDK: the document.location.href is directing to an incorrect page

Hello Community of Developers, I have been experimenting with different methods but still haven't found a solution. In my project using Intel XDK, whenever I attempt to change the page using location.location.href = "#EndGame" or similar codes in Java ...

Using ng-value does not trigger any updates to the Ng-model

After setting the input value Array property sum, it displays the value in the input field. However, when submitting the form, the Quantity property is not being received in the Order object. I noticed that if I change the value manually, then the Quanti ...

Setting the z-index for a JavaScript plugin

I need help with embedding the LinkedIn plugin into a website that has stacked images using z-index for layout. I have tried assigning the plugin to a CSS class with a z-index and position properties, but it hasn't worked as expected. Can anyone sugge ...

Animate.css glitch: The webpage grows exponentially

While using animate.css to add animations to some elements, I noticed that when applying the classes fadeInRight and fadeInLeft, a strange issue occurs just before the animation finishes - the bottom scroll bar briefly appears. This is something new for m ...