How to incorporate an SVG line between two divs within a flexbox arrangement

<div class='container'>
 <div class='Greeting'>
   Hello there this is B
 </div>
 <div class='banana'>
   Hello B
  </div>
</div>



.container{
      display: flex;
      width: 100%;
      justify-content: space-between;
    }

Having a container div with two nested divs. The goal is to create an svg line between them while accounting for variable text lengths. How can the length of the space between be calculated?

Answer №1

Feel free to utilize this code snippet.
I opted for using the CSS property border, instead of svg.
The line spans the entire width due to the use of flex-grow: 1 and flex-shrink: 1.

.parent{
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
}
.line {
  border-top: 2px solid black;
  flex-grow: 1;
  flex-shrink: 1;
}
<div class='parent'>
 <div class='Hi'>
   Hi there this is A
 </div>
 <div class="line"></div>
 <div class='apple'>
   Hi A
  </div>
</div>

https://i.sstatic.net/QC5m6.png

It can be seen that the content is now perfectly centered.

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

What's the best way to arrange my containers for optimal placement?

I'm attempting to create a Thymeleaf template for rendering a printable PDF. Here is what I currently have: <html xmlns:th="http://www.thymeleaf.org" > <head> <meta name="viewport" content="width=device-width, initial-scale=1.0" ...

tips for personalizing your jQuery image preview script

Currently, I have implemented a jQuery script that allows me to preview multiple images before uploading them. Although the functionality works well, I am facing difficulties customizing it to meet my specific requirements. <script> $(document).r ...

inject custom styles into a Material-UI styled component

Although I have come across similar questions, none seem to directly address my current situation. I am in the process of transitioning from MUI v4 to MUI v5 and have encountered various scenarios where a specific style is applied externally. For instance ...

Global error handling for URQL GraphQL mutation is a critical aspect that needs to be effectively implemented

Here's the technology stack I'm using: react v17.0.2 graphql v16.8.0 graphql-ws v5.14.0 urql v4.0.5 I rely on Hasura Actions to interact with a REST API and am in need of a solution for handling global errors for all mutations. For instance, I ...

Superimposing a division on top of an image using React

I'm having an issue with overlaying a div on top of an image when it's clicked in my React project. I've successfully added the div to other elements on the page, but for some reason it won't work on the image. Here's the componen ...

The URL is unresponsive following the deployment of the production build in tailwind

The image URL in my project is functioning correctly in the VITE server environment before the production build. However, after the production build, it fails to display the correct path of the image in the HTML. All other images are displaying properly ex ...

Executing npm install for a nearby dependency within a Dockerfile

I'm currently working on creating a Docker image for a react js app that has a local dependency, similar to what was discussed in this thread. The issue I'm facing is that when I attempt to build and run the image, I encounter the following error ...

When executing react-scripts test, an error message "Error: spawn git ENOENT" appears

A few days ago, I created a new project using the create-react-app. Initially, the tests were running smoothly without any issues. However, when I tried to run the tests again after not touching them for some time, I encountered the following error: Deter ...

Refreshing Django HTML table dynamically upon database updates

Currently, I have an HTML table set up using a Django template to showcase data from my database. I am looking to ensure that this table remains updated in real-time whenever the database undergoes changes. Despite my research efforts, there is limited inf ...

Using JQuery to modify several background images in unison

I have a CSS code that uses 8 images to create a frame: background-image: url(images/blue/tl.png), url(images/blue/tr.png), url(images/blue/bl.png), url(images/blue/br.png), url(images/blue/t.png),url(images/blue/b.png),url(images/blue/l.png),url(images/b ...

Using conditional rendering to set an icon in a ChipField component in React Admin

One feature in my React Admin App is a Datagrid with a ChipField displaying a text property. I want to enhance this by adding an icon to the ChipField using the icon prop, which should change based on the text value. This is my current approach: expor ...

Implementing PHP logic for adding a class to an HTML tag

I have a PHP file that handles the sending of my form. Everything is functioning correctly, but I need to make a small modification. When the message is successfully sent, I want PHP to dynamically add the "active" class to a specific div in my HTML. This ...

Can I use AJAX to load an entire PHP file?

My goal is to trigger a PHP file for sending an email when the countdown I created reaches zero. The PHP code contains the email message and does not involve any UI elements. I suspect that my approach may be incorrect, especially since I am not very fami ...

Learning to access dynamic form elements in React NativeUncover the secrets of interacting

I am facing a challenge with dealing with dynamic form elements in my React page. I'm not quite sure what the best approach would be for reading all the input values and storing them to the state, or if there are any other solutions available. Any sug ...

JavaScript: Can you clarify the value of this variable using five sets of double quotations?

Could you please review the code snippet below for me? <script type="text/javascript"> function recentpostslist(json) { document.write('<ul class="recommended">'); var i; var j; for (i = 0; i < json.feed.entry.length; i++) { ...

Should you choose a pre-built CSS framework or create your own from scratch?

Have you come across a framework that meets your project needs with just a few tweaks, or have you forged your own path along the way? What advice do you have for someone facing this decision and focusing on priorities like: Implementing a CSS reset Refi ...

Enhance website performance by optimizing pagespeed score for pages containing a Vimeo video on the initial view

I recently launched a website in NextJS 13 that is known for its impressive speed. One of the key features of the site is a video from Vimeo embedded on the first screen. To ensure that the Vimeo iframe does not negatively impact the page speed, I have ex ...

What is the best method to customize CSS in ExtJS 5.0 by overriding a function?

Is there a way to dynamically add a rule to existing CSS using code, particularly in overrides? For example: var sheets = document.styleSheets; // Some code omitted for simplicity var sheet = sheets[sheets.length - 1]; sheet.insertRule('.overlay {flo ...

jQuery failing to append code after being removed

I need some assistance with an issue I've run into while using jQuery's .remove(). Here is a snippet of code that showcases the problem: $( '.video-button span.glyphicon-play' ).click(function() { $( '#video-player' ).ap ...

I encountered an issue with Material UI tabs showing the error message: "Failed prop type: The prop `children` is not supported. Please remove it."

Recently, I started using Material UI tabs in my project for the first time. Everything seems to be working fine except for one issue that keeps showing up in the console while running the project: Failed prop type: The prop `children` is not supported. Pl ...