Conceal the lower border using CSS until the content is fully loaded

loading issue screenshot An interesting problem has arisen in my project. I have implemented a label box within a div using a for loop. The label has a CSS property for bottom-border. However, upon page load, only the bottom border line is visible. It's not until the content loads and the images appear in the img tag that everything becomes fully visible. What I want to achieve is to remove the bottom border during the loading process. To accomplish this, the [hidden] variable is initially set as false, which changes after data is retrieved through subscription.

The relevant code files are provided below:

.html file

<div [hidden]="varible" class="wrapper">
  <div class="tab" *ngFor="let items of itemsData?.data;let i=index;">
    <input id={{i}} type="checkbox" name="tabs">
    <label for={{i}}>
      <img src={{items.imgSrc}}>
      <span>{{items.title}}</span>
    </label>
  </div>
</div>

.scss file

wrapper {
    height: calc(100vh - 3.5em);
    overflow-y: scroll;
    .tab {
        position: relative;
        margin-bottom: 1px;
        width: 100%;
        color: #fff;
        overflow: hidden;
    }
    .tab input {
        position: absolute;
        opacity: 0;
        z-index: -1;
    }
    .tab label {
        position: relative;
        display: block;
        font-weight: bold;
        color: #444;
        cursor: pointer;
        // Specific solution added here
        margin-left: 16px;
        margin-right: 16px;
        img {
            margin: 10px 10px 10px 0px;
        }
        span {
            position: relative;
            bottom: 22px;
            font-size: 13px;
            color: #666666;
            letter-spacing: 0.59px;
            font-weight: 500;
        } 
    }
}

.ts file

public varible: boolean = true;
ngOnInit() {

    this.service.getResults().subscribe(
      (response: any) => {
          this.searchItemsData = response; 
          this.varible= false;
      },
      error => {
        console.log(error);
      }
    );
  }

Answer №1

To create a border, add a flag and set it to false initially. Update it to true after the content has loaded.

In your HTML, include:

<div [hidden]="variable" class="wrapper">
  <div class="tab" *ngFor="let item of itemsData?.data; let i=index;">
    <input id={{i}} type="checkbox" name="tabs" [ngStyle]="{'border-bottom': bottomBorder ? '1px solid #E9E9E9' : ''}">
    <label for={{i}}>
      <img src={{item.imgSrc}}>
      <span>{{item.title}}</span>
    </label>
  </div>
</div>

In your TypeScript file:

this.bottomBorder = false;    
ngOnInit() {
        this.service.getResults().subscribe(
          (response: any) => {
              this.searchItemsData = response; 
              this.variable = false;
              this.bottomBorder = true;
          },
          error => {
            console.log(error);
          }
        );
      }

EDIT: Also remove the bottom border from the CSS

Answer №2

<section [hidden]="checkVar" class="container">

this sentence should be modified as follows:

<section [hidden]="checkVar == true" class="container">

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

Learn the art of closing an AngularJS accordion automatically when another accordion is opened within an AngularJS application

I have encountered an issue with the AngularJS accordion functionality. It seems that when I have multiple accordions, such as accordion-1, accordion-2, and accordion-3, they all open simultaneously if clicked on individually. My main concern is: How can ...

Do jQuery and AJAX both support application/json content type in all web browsers?

I have been managing my ajax requests like this: @header("Content-Type: text/html; charset=".get_option('blog_charset')); and in the JavaScript: $.ajax(.... ... success: function(response){ var obj = eval('('+response+') ...

Show a DialogBox taking up the entire screen

In my HTML page, I have implemented a frameset with two frames. The first frame contains a button that, when clicked, displays a dialog box. However, the issue is that the dialog box only appears in the top frame and not on the entire screen. Is there a wa ...

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 ...

The color attribute does not apply to the v-list-tile element in Vuetify

My list setup is not allowing me to set a color for a v-list-tile as it remains uncolored. Below is the template code: <v-container> <v-flex xs12> <v-card color="rgba(75,75,75,1)"> <v-card-title><h4>D ...

How to Make an Element Fade Out After Adding a Class in JQuery

I'm struggling with fading out an image after applying a tilt class to it. The transition doesn't seem to work properly and the image just disappears without the expected animation. The class I'm trying to add simply tilts the image 90 degr ...

The dropdown menu is currently activated, but not the individual items within it

Is there a way to make the dropdown menu active when I click on an item, specifically making the word Services active? How can this be achieved? <nav class="navbar navbar-light navbar-expand-xl"> <a class="navbar-brand" hre ...

Activating external actions from the ngrx store through component interactions

I am working with a module that contains a modal where I perform some form tasks, and the modal has its own small feature store. After completing my work (specifically, when a save is successful), I need to trigger an output event in order for the parent ...

What is the process of Defining an Element Based on Two Attributes in C#?

Is it feasible to specify a web page element based on two attributes? For example, I can locate the element by its innertext Element imagePage = ActiveBrowser.Find.ByContent(pageNumbers[p],FindContentType.InnerText); Alternatively, I can identify an ele ...

Tips for removing focus outlines on button clicks

Whenever I click on my buttons, they all have a highlighted border around them. This issue is occurring in Google Chrome. <button class="btn btn-primary btn-block"> <span class="icon-plus"></span> Add Page </button> I am cu ...

Enhancing Dynamic Dropdowns with the Latest JQuery Updates

I am facing an issue with my jQuery function that updates input boxes when a dropdown option is selected. I have also implemented an addRow function to dynamically add more selects, but the jQuery function does not work for the newly added selects. Below i ...

Using the component property to adjust the rotation attribute in an SVG element

Just getting started with Angular2 and running into a simple issue. I'm trying to display rotated texts with dynamic x positions (currently using static tab). See my code below: myComponent.ts : import { Component, OnInit } from '@angular/core& ...

Display Descriptions Upon Hovering Over Images

I am attempting to utilize JavaScript to display the caption of an image only when it is being hovered over, and to have a default caption shown when no image is being hovered. <ul class="logos"> <li class="image-1"></li> <li ...

Ion-content - Consisting of three elements with varying vertical positioning

I've been facing a challenge trying to include 3 different components (such as buttons, images, etc.) with distinct vertical alignment within the same ion-view. One should be aligned at the top, one in the middle, and one at the bottom. Take a look a ...

The error message "Cannot redeclare block-scoped variable 'tz'" is shown when trying to use Ionic 2 along with angular-moment-timezone

Today, I installed angular-moment-timezone in my Ionic project and everything was working fine. However, after removing the node_modules folder and then running npm i, I started getting errors whenever I tried to run ionic serve. These are the errors I am ...

Scroll pagination and sorting in Angular 4

Currently delving into Angular 4 and still getting the hang of things. Attempting to implement a table(grid) with scroll pagination and sorting abilities. Has anyone come across a component that enables this functionality? ...

Achieving both vertical and horizontal center alignment specifically for mobile devices

Is there a way to center a column on mobile devices only while maintaining a fixed height for the section? <div class="" style="background-image: url(image url;); background-position: right bottom; background-size: cover; height: 462px;"> <div cl ...

JHipster form validation is failing to function properly

I have a specific class structure that is defined as follows in JDL entity Address { address String required, city String required, postalCode String required, country String required, } entity MainEntity { <some fields> } relationship O ...

Guide on integrating CSS into a Vue Bootstrap table design

I am having trouble adding a CSS to my bootstrap vue table template. <template slot="actions" slot-scope="data" :style="{min-width:'150px'}"> <b-button variant="info" @click="showViewModel(data.item)"> <i class="fa fa-e ...

The hierarchical structure in the DOM that mirrors an HTML table

While working on code to navigate the DOM for a table, I encountered an unexpected surprise. The DOM (specifically in FF) did not align with my initial expectations. Upon investigation, it appears that FF has automatically inserted a tbody along with sever ...