The use of AngularJS ngBind is causing layout issues with the div element when viewed on smaller screens

I'm encountering a strange issue while attempting to inject text from the database into an HTML template using AngularJS. Everything appears fine until switching to mobile view or when the screen size is very small.

Here is my HTML template:

<div class="col-12">
<div class="panel panel-white no-radius">
   <div class="panel-heading border-bottom">
      <h4 class="panel-title">Review</h4>
   </div>
   <div class="panel-body padding-left-20 padding-right-20">    
       <div ng-repeat="reviewer in reviewers">
         <div class="row">
             <a href="#" class="pull-left"> <img alt="image" class="img-circle" src="assets/images/avatar-2.jpg"> </a>
             <strong>{{reviewer.FirstName}} {{reviewer.LastName}}</strong>
         </div>
         <div class="row">
           <div class="well" style="height: 100px; overflow:auto; word-wrap:break-word;" >
             {{reviewer.Review}}
           </div>
         </div>
       </div>
   </div>
   <div class="panel-footer" ng-if='rate'>
                Please leave <strong>{{name}}</strong> a review:
     <textarea class="form-control" ng-model='review' maxlength="900" style="resize:vertical;" rows="3"></textarea>
     <button ng-if='rate' class="btn btn-primary btn-xs margin-top-3" ng-click="leaveReview(review)">Leave review</button>
  </div>
 </div>

The textarea on the footer is where I input the review into the database. What I've noticed is that if I simply insert text into the HTML file, the layout looks perfect. However, when utilizing ngBind, the text causes the div to widen on smaller screens (specifically, when resizing).

My assumption is that the textarea adds hidden characters to the input, which then interfere with the div (possibly newlines or something similar).

Apologies if the HTML indentation isn't correct.

Answer №1

You seem to have missed closing the div tag, probably just a typo while posting.

The issue is not related to AngularJS, it's more of a design problem.

When using bootstarp, there is no need for the row class inside the col-12 class.

I believe that could be causing the design problem. You are binding data to a div inside another div with the row class, whose parent is yet another div with the col-12 class.

You can simply remove the row class and see if that resolves the issue.

For a clearer explanation, check out this link where the layout is highlighted with red and green colors.

<div class="row">
 <div class="col-sm-4" style="background-color:red">
  <h3>Column 1</h3>
     <div class='row'>
        <div  style="background-color:green">This is with "row" inside "column grid". This is with "row" inside "column grid". This is with "row" inside "column grid". This is with "row" inside "column grid". This is with "row" inside "column grid".</div>
     </div>
 </div>
 <div class="col-sm-4" style="background-color:red">
  <h3>Column 2</h3>
     <div  style="background-color:green">This is without "row" inside "column grid". This is without "row" inside "column grid". This is without "row" inside "column grid". This is without "row" inside "column grid". This is without "row" inside "column grid". </div>
 </div>
 </div>
 <div class="col-sm-4">
  <h3>Column 3</h3>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit...</p>
    <p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris...</p>
</div>

https://jsfiddle.net/qh5n27bx/

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

Ensuring compatibility with a wide range of video formats across all web browsers

As I develop an application that allows users to upload videos, it's crucial for them to have the freedom to upload popular video formats like .mov and .mp4. However, I've discovered that most browsers do not support .mov files. I've attempt ...

What could be causing my date to not format correctly as intended?

I have a date stored in my database table that appears like this: "2017-12-07 14:42:38.0611177 +00:00" When I try to format it in my HTML using this code: <td>{{ note.CreatedAt | date : "MMM d, y" }}</td> I anticipate the date to be display ...

Unable to interact with the <svg></svg> element and enter the desired value

The <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">...</svg> cannot be clicked and the value of <input class="opacity-0 absolute top-0 lef ...

Load and execute a dynamically created script in JavaScript at the same time

I am exploring the option to load and evaluate a script from a third-party synchronously. Here is an example that currently works well: <head> <script src="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfe ...

The Art of CSS Arrangement

I'm experiencing an issue on my website PSR Is there a way to ensure that the Footer always appears below the content div automatically? Both the Content and the Footer have relative positioning. Additionally, how can I make the Footer the same siz ...

AngularJS - Import and save CSV files

I have set up a nodeJS program as the server and an AngularJS web application as the client. For generating CSV files, I am utilizing the "express-csv" library (https://www.npmjs.com/package/express-csv) Below is the code for the server side: Definition ...

Retrieve data from an HTML form within an Angular 2 ag-grid component

I'm facing a challenge with incorporating form values from a modal into an ag-grid array in my HTML file. I'm unsure of the process to achieve this. Below is an excerpt from my file.html: <template #addTrainContent let-c="close" let-d="dismi ...

What is the best way to target children elements within individual instances of a specific class?

Below is a snippet of the code I am working with. <div class="row"> <div class="column"> </div> <div class="column"> </div> </div> <div class="row"> <div class="column"> </div&g ...

modifying variable values does not impact what is displayed on the screen

I'm currently facing an issue with AngularJS. I have two HTML blocks within an ng-repeat and I need to display one of them at each step. <div class="col-md-3" style="margin-top:80px" ng-init="checkFunction()"> <div id="left_group_stage"& ...

What is the best way to make a div pull its background image directly from the internet instead of using the cached version?

Running relevant Javascript every fifteen minutes to fetch the appropriate image from the internet: document.getElementById('weatherbug').style.background = "url('http://tinyurl.com/jwltx5s') repeat scroll -1px -24px transparent"; The ...

accessing the angular fullstack default application by authenticating via google oauth2

Currently, I have my angular fullstack application running on localhost:9000. I am trying to implement a feature that allows users to log in by clicking the "Connect with Google+" button on the login page. However, I keep encountering an error 400 with th ...

Retrieving JSON data in an array using $http method in AngularJS

Recently, I came across an issue where I had to delete an older post but was able to resolve it. However, I am now facing a new problem: After receiving a data array from PHP using $http (as shown in the console.log output below), I am unable to access th ...

Utilize the ::before selector to insert white spaces

I attempted this solution, but unfortunately it did not produce the desired outcome: .stackoverflow::before { font-family: 'FontAwesome'; content: "\f16c "; } <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-aw ...

CSS Tricks: Placing a Panel Just Off the Page Edge

Having difficulty adjusting a panel slightly off the page like this: click here for image Attempted using width: 120% While it does work, resizing causes the image to move from its original position. I want it to remain consistent on different screens. ...

Steps to eliminate cell padding within a table

I am currently working on a betting application using Angular 12. I am facing an issue with the spacing in cells, as there is excessive cell padding that is causing wastage of space. <table class="w-100 text-white"> <tbody> <tr ...

Encountered an issue while trying to synchronize with the page using Protractor: "Unable to find window.angular"

I am relatively new to using Protractor and have successfully created several page objects. So far, everything has been working smoothly. However, I recently encountered an issue after logging in to a page and being redirected to the myaccount page. Upon ...

Converting time zones from local to UTC using AngularJS

Currently, I am utilizing the variable date= new Date(); within my controller to retrieve the current local time. The resulting output appears as follows: var date=Mon Aug 03 2015 07:56:55 GMT +0530(India Standard Time) However, I actually require UTC ...

Ways to adjust the width for the col-xs class in Bootstrap

Hey, I've been searching with no luck on how to change the default value of col-xs-12. I attempted to make some changes but ended up breaking everything... .col-xs-12 { width: 600px; } If anyone has a solution or knows where I can find one, that ...

What is the most effective method for transitioning between states in Angular when it comes to modifying the HTML display?

When faced with the decision of choosing between two different approaches for managing component view during loading, the "best way" refers to performance and minimizing UI blinking (reducing DOM renderizations). Approach 1: Utilize a loading variable to ...

Guide to rendering the chosen option of an input dynamically in EJS

I have a dropdown menu where users can select an option to send to the database. Now, when they revisit the page, I want them to see the option they previously selected. Using EJS templating: <div class="form-group col-sm-6" style="width: 50%;"> ...