Adjusting the height property to zero in the absence of an element

I'm currently working on creating a timeline for changeLogs and populating it with data from an AngularJS controller. The issue I'm facing is that the height of the timeline "Line" is set to 6px. This means that even when there is no data in the controller, a 6px line is still displayed in the view.

What I'd like instead is for the line to have a height of 0px when there is no data, and a height of 6px when data is present.

Here's a snippet from the CSS

.timeline {
        position: relative;
        padding: 1em 0;
        list-style-type: none;
        overflow-x: hidden;
    }

    .timeline:after {
        position: absolute;
        left: 120px;
        top: 0;
        content: ' ';
        display: block;
        width: 6px;
        height: 100%;
        background: #636e72; /*Color of horizontal line*/
        z-index: 5;
    }

Here's a snippet from the HTML

<ul class="timeline">
   <li ng-repeat="log in changelogCtrl.logs | orderBy: '-dateObj'">
           <span class="direction-l">
              <span class="flag-wrapper">
                   <span class="flag">
                       <span class="time-wrapper">
                          <span class="time">
                             {{log.date}}
                          </span>
                       </span>
                  </span>
             </span>
          </span>
          <div class="direction-r move-left">
              <div class="flag-wrapper">
                  <div class="flag">
                     <strong>{{log.module}}</strong>&nbsp;<strong class="fa fa-long-arrow-right"></strong>&nbsp;{{log.subModule}}
                  </div>
              </div>
              <div class="desc">
                 {{log.desc}}
              </div>
              </div>
          </li>
       </ul>

Answer №1

Check this out!

.timeline {
        position: relative;
        padding: 1em 0;
        list-style-type: none;
        overflow-x: hidden;
    }

    .timeline:not(:empty):after {
        position: absolute;
        left: 120px;
        top: 0;
        content: ' ';
        display: block;
        width: 6px;
        height: 100%;
        background: #636e72; /*Color of horizontal line*/
        z-index: 5;
    }

<p class="timeline"></p><!--without any content-->
<p class="timeline">with some content</p>

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

Navigating between multiple Angular applications using Express

In my project, I am facing an issue with the file structure. I have a server folder and a client folder which includes two Angular apps: one for the website and one for the dashboard. If you want to check out the code, it's available at this link. A ...

I'm having trouble displaying the X's and O's in my tic tac toe JavaScript game. Any suggestions on how to resolve this issue?

After following a couple of online tutorials for the tic tac toe project, I encountered an error in both attempts. The X's and O's were not displaying even though all other features were working fine. Below are my codes for HTML, CSS, and JavaScr ...

Are there specific mathematical algorithms that lend themselves well to creating responsive HTML designs?

Tired of constantly guessing the percentage values to use with a specific number of divs and other elements in my design. I am looking to understand the mathematical calculations that determine the scaling required for different elements in order to main ...

Unable to utilize the rupee font within a select element on Chrome and IE8 browsers

Issues with displaying rupee font in select element on Chrome and IE8 I have implemented WebRupee for showing the Indian currency symbol. The font appears correctly when used within a <p> tag, but when placed inside a select option element, it only ...

Approach for calculating the total of values during an iteration

I am working with the array $scope.otherDetailsData [0] object amount: 29.9 code: "012" currency: "BRL" payedDate: "2016-11-10" roDate: "2016-08-01" type:"OTHER" [1] object amount: 39.9 code: "013" currency: "BRL" payedDate: "2016-11-11" roDate: "2016- ...

The hover effect is not functioning properly after loading jQuery with load();

When loading elements into a div using the load() function, I noticed that the :hover effect in CSS stops working for those elements. It's a dynamic menu setup, as shown below: <div id='main-menu'> <ul> <li class='click ...

Directing JSON POST Request Data to View/Controller in a Node.js Application

Currently, I am working on a project hosted on a local server at http://localhost:3000/. This server receives a post request from another server in the following manner: return requestLib.post({ url: 'http://localhost:3000/test', timeout ...

Discover the method for accessing the attribute of an Angular directive within the HTML content of the templateUrl

Can anyone help me understand how to access the attribute of an angular directive in the HTML content specified in templateUrl? angular.module('myApp') .directive('questionImage', function () { return { restri ...

Is there a way to potentially utilize window.open() to open a specific section of a webpage?

My HTML page consists of 2 div blocks and 2 links. I want to open the content of the first div in a new window when the first link is clicked, and the content of the second div in another new window when the second link is clicked. You can find the code h ...

adjust back side height of flip box does not function on IE web browser

I'm currently working on flipping a div/box, and while it's functioning correctly, I'm facing an issue with the height of the back side exceeding that of the front side. This causes the flipped div to always push down to the next element (e. ...

Add fresh inline designs to a React high-order component creation

Applying a common HOC pattern like this can be quite effective. However, there are instances where you may not want a component to be wrapped, but rather just extended. This is the challenge I am facing here. Wrapper HOC const flexboxContainerStyles = { ...

Exploring the Possibilities with AngularJS Location Filtering

My single-page application (SPA) includes select lists used for filtering locations based on region, state/province/EU country, and city. Although I have managed to set up filtering to some extent, there are issues with the lat/lng values of the locations ...

Troubleshooting HTML/CSS and JavaScript Issues with Dropdown Menus

I'm having trouble getting my dropdown menu to work properly and I can't figure out why. The JavaScript code should toggle a class that hides the language options and slides up the other tabs like "Contact". However, when I click the button, noth ...

Sass flex order has no effect on elements that are generated

I encountered an issue with the rendering of SVGs in my project. Currently, they are displayed correctly in desktop mode, but in mobile portrait mode, I need to change the order of one specific SVG element within the row. To achieve this, I decided to use ...

Exploring Bootstrap 4: Creating list-inline elements for various screen sizes

Is there a way to align list items on top of each other for a breakpoint <=575px (xs), and align the items next to each other for a breakpoint >575px (sm) using Bootstrap display properties? I found some information on How to display a list inline u ...

Limitation on repetitive values in AngularJS push function

In need of a restriction to prevent duplicate values from being entered. The user can click on the Add button, which will then display a text field for inputting data. AngularJS will check if the inputted data is a duplicate or not. If it is not a duplicat ...

What is the best way to retrieve information from a JSON string?

I am currently receiving a JSON object from the backend and I only need the "result" array in my Angular application template variable. { "result":[ {"name":"Sunil Sahu", "mobile":"1234567890", "emai ...

Creating a Node.js Application Directory

As someone who is brand new to Node.js and navigating the command line, I may be asking a basic question, but I've hit a roadblock. My issue stems from setting up an app directory using Node.js and NPM. Each time I attempt to use port 5000, I encount ...

What is the best way to continuously make an ajax request in Angular.js and terminate it depending on the response received?

I am looking for advice on how to optimize my controller in order to run a periodic ajax call every 15 seconds instead of just once. Additionally, I am wondering how I can stop the call when needed. myApp.controller('myCntrl', function($window,$ ...

JQuery ID Media Queries: Enhancing responsive design with targeted

Is it possible to integrate a media query into the selection of an ID using JQuery? For example: $('#idname') $('@media (max-width: 767px) { #idname }') In essence, can you target the #idname with that specified media query in JQuery ...