Horizontal Line Connectors for CSS Organization Charts

I am struggling with the CSS organization structure. The line connectors are not aligning properly with the node elements. I need assistance in positioning them correctly. JSFIDDLE

CSS styling:

* {
  margin: 0;
  padding: 0;
}

.tree img {
  width: 75px;
}

.tree {
  width: 1994px;
}
/* More CSS code here */

HTML Code:

<div id="" class="tree">
  <ul>
    <li>
      <div class='emplist'>
        <div class='deptRow'>
          <h3>Research & Development</h3>
        </div>
        <hr>
        <div class='detailsRow'>
          <div class='detailsCol'>
            <h3 class='empName'>Emp1</h3>
            <p class='subTitle'>Research & Development
              <br/>Hyderabad</p>
          </div>
          <div class='imgCol'><img src='' alt='abc' /></div>
        </div>
        <hr>
        <div class='infoRow'>
          <div class='infoMoreR pull-right text-right'>
            <button id='btn_empModal' data-toggle='modal' class='btn btn-xs text-center'>info</button>
          </div>
          <div class='infoMore'>
            <p id='leafCount'></p>
          </div>
        </div>
      </div>
      <ul>
        <li>
          <div class='emplist'>
            <div class='deptRow'>
              <h3>emp2</h3>
            </div>
            <hr>
            <div class='detailsRow'>
              <div class='detailsCol'>
                <h3 class='empName'></h3>
                <p class='subTitle'>Research & Development
                  <br>Hyderabad</p>
              </div>
              <div class='imgCol'><img src='' alt='abc' /></div>
            </div>
            <hr>
            <div class='infoRow'>
              <div class='infoMoreR pull-right text-right'>
                <button id='btn_empModal' data-toggle='modal' class='btn btn-xs text-center'>info</button>
              </div>
              <div class='infoMore'>
                <p id='leafCount'></p>
              </div>
            </div>
          </div>
          <ul>
             /* Nested list items here */
          </ul>
        </li>
      </ul>
    </li>
  </ul>
</div>

If you have any suggestions or improvements for the above code, please let me know as soon as possible.

Answer №1

.emplist {
  width: 320px !important;
  height: 160px !important;
  border: 1px solid #aaa;
  border-radius: 5px;
  color: #333;
  transition: box-shadow 1s;
  position: relative;
  cursor: move;
}

Replace the code block above with the modified version below:

.emplist{
    width: 320px !important;
    height: 160px !important;
    border: 1px solid #aaa;
    border-radius: 5px;
    color: #333;
    transition: box-shadow 1s;
    position: relative;
    cursor: move;
    display: inline-block;    
}

This updated version includes the addition of the 'display' property.

Answer №2

Ensure you include this snippet in your CSS file.

div {
margin:0px auto;
}

The issue lies in the margin property set to "0px" in your current CSS. You may want to adjust the margin-left and margin-right properties to "auto" as needed.

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

How do I customize the appearance of an Element-UI data table in Vue?

I'm struggling to customize the color of an Element UI datatable in my project. I've tried several approaches, but so far, nothing has worked. Here is the code I am currently using: <template> <el-table :data="tableData.filter ...

Is there a way to incorporate text fields and input in BootstrapDialog?

Is it possible to include text fields and inputs within this modal using BootstrapDialog without modifying the library? Additionally, can I use $.ajax() inside? <button class="btn btn-primary" id="add_item">New item</button> jquery $('# ...

Can you identify the animation being used on this button - is it CSS or JavaScript?

While browsing ThemeForest, I stumbled upon this theme: What caught my eye were the animation effects on the two buttons in the slider ("buy intense now" and "start a journey"). I tried to inspect the code using Firebug but couldn't figure it out com ...

Guidelines for pinpointing local directories

Recently, I obtained a source code for a website navigation that includes a unique set of icons known as "Typicon." The HTML in the source code contains the following: <link rel="stylesheet" type="text/css" href="css/component.css" /> Within the C ...

Interacting with a button element specified with the role attribute inside a div container using Selenium

Is there a way to interact with the button using the HTML tag provided below? <div class="_1WZqU PNlAR" role="button">OK</div> I attempted the following methods: driver.findElement(By.xpath("//button[text()='OK']")).click(); driver ...

What methods can I use to toggle between different divs using navigation buttons?

There are 4 divs on my webpage that I need to toggle between using the up and down arrows. Despite trying an if else statement, it doesn't work as intended. <link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.c ...

When viewing HTML "Div" on smaller screens, the full height may not be displayed properly

My setup includes two monitors: one is 24" and the other is my laptop's 12.5" screen. I have a red box (div) in my web application that displays full height on the larger monitor, but only partially on the smaller one. I'm puzzled as to why it s ...

Using content delivery networks (CDNs) to showcase the modal drawer example with Material Components for

Exploring different ways to implement Material Components for Web can be quite challenging, especially when relying on CDNs for front-end design. While searching for examples, I came across a demo of a modal drawer. However, it appears that the demo does ...

Finding the Xpath for an element that contains only a span tag, with identical attributes except for the text within

I am struggling to find the xpath for a button element that says 'Cancel'. <div class="uipresk"> <button class="something" role="button" type="button"> <span class="thisthing">OK</span> </button> ...

The device-width value in the viewport width setting is causing issues

My angular app desperately needs a mobile responsive design as it currently looks dreadful on mobile devices. I've tried adding <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, user-scalable=yes">, but ...

Retrieve the Nth class of an element that has multiple classes without relying on the .attr("class") method in jQuery

Within a container with two styles, the initial nested div <div class="datacheck"> <div class="classic_div_data customdataid_305"> some values are included here </div> <div class="optiondiv"> </div> </div& ...

Attach the footer to the bottom of the screen only if the main page text is limited in length

How can I ensure that my footer sticks to the bottom of the screen only when there is minimal content on the page? When there is a lot of content, I'd like the footer to appear after the content rather than being pinned at the bottom, especially since ...

AngularStrap's bs-modal is failing to display content

I have a question, here is a Plunker with the code: http://plnkr.co/edit/SNFy2XcOBefUavG1QCqD?p=preview <button class="btn btn-default" data-template="customer.tpl.html" bs-modal="modal">New Customer </button> < ...

"Utilizing SVG format to manipulate text, adjusting font size within tspan elements

There seems to be an issue with the font size on SVG. Even though both the SVG and paragraph have a font-size of 16px, they appear different. I would like the font size in the SVG to match that of the paragraph. Another concern is how to center <tspan ...

Using the "export default" feature in React.js is a

Is it possible to name an exported function as "default" without encountering an error? export default() => { const [width, setWidth] = useState(0); const [height, setHeight] = useState(0); useEffect(() => { setTimeout(() => { setWidth(window.i ...

determine the width of the container

I was having a debate with a friend the other day, and we came across an interesting example. The question at hand is whether the container has a width of 500px or 580px. When we say "content," we are referring to the space between the sides of the banner ...

How can I add color to arrow icons in tabulator group rows?

Is there a way to specify the color of the arrows in collapsed/expanded group rows? Also, what CSS code should I use to define the font color for column group summaries? You can view an example of what I am trying to customize here: https://jsfiddle.net/s ...

What separates text-align:center from margin auto?

As someone who is just beginning to learn about CSS, I have come across the properties: text-align:center; and margin:auto; Both of these seem to center elements, but how exactly do they differ from each other? Any insights would be much appreciated. T ...

Utilizing a single video format for HTML5 video playback

Adobe's announcement to phase out Flash Player by the end of 2020 has raised concerns about the migration of Flash content to HTML5. While many agree that this transition is necessary, there are questions about how ready HTML5 is to replace Flash enti ...

Unable to toggle Bootstrap 5 tabs in a Nunjucks template - the issue persists

I have been following the bootstrap documentation for tabs which can be found at this link After referencing the documentation, I replicated the sample implementation in my code as shown below: --- title: Portfolio description: Portfolio --- {% exten ...