Tips for effectively handling responsive design within an Angular application

Is there a way to add the static text and text box horizontally instead of vertically when clicking on the add button? How can I make this design responsive?

For Desktop/Laptop: display 4 items in a row. For Tablet: display 3 items in a row. For Mobile: display 1 item in a row.

I have attached the HTML, JavaScript, and CSS files for reference. Any suggestions are appreciated.

var app = angular.module('angularjs-starter', []);

app.controller('MainCtrl', function($scope) {

  $scope.choices = [{id: 'choice1'}, {id: 'choice2'}];

  $scope.addNewChoice = function() {
    var newItemNo = $scope.choices.length + 1;
    $scope.choices.push({'id': 'choice' + newItemNo});
  };

  $scope.removeChoice = function() {
    var lastItem = $scope.choices.length - 1;
    $scope.choices.splice(lastItem);
  };

});
fieldset {
  background: #FCFCFC;
  padding: 16px;
  border: 1px solid #D5D5D5;
}
.addfields {
  margin: 10px 0;
}

#choicesDisplay {
  padding: 10px;
  background: rgb(227, 250, 227);
  border: 1px solid rgb(171, 239, 171);
  color: rgb(9, 56, 9);
}
.remove {
  background: #C76868;
  color: #FFF;
  font-weight: bold;
  font-size: 21px;
  border: 0;
  cursor: pointer;
  display: inline-block;
  padding: 4px 9px;
  vertical-align: top;
  line-height: 100%;   
}

input[type="text"],
select {
  padding: 5px;
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.min.js"></script>

<div ng-app="angularjs-starter" ng-controller="MainCtrl">
  <fieldset data-ng-repeat="choice in choices">
    <select>
      <option>Mobile</option>
      <option>Office</option>
      <option>Home</option>
    </select>
    <input type="text" ng-model="choice.name" name="" placeholder="Enter mobile number">
    <button class="remove" ng-show="$last" ng-click="removeChoice()">-</button>
  </fieldset>
  <button class="addfields" ng-click="addNewChoice()">Add fields</button>

  <div id="choicesDisplay">
    {{ choices }}
  </div>
</div>

Answer №1

To ensure responsiveness, consider utilizing Angular Material or Bootstrap

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

Is there a different value for -webkit-filter: brightness() in Safari? Any tips on how to adjust for this

It has come to my attention that Safari prefers the brightness setting for the -webkit-filter to be a percentage, while other browsers use a less straightforward scale. Take note of the difference in brightness changes between Chrome and Safari in the fol ...

Tips for showcasing and modifying MVC ApplicationUser attributes

I am looking to customize the display and editing of a ApplicationUser using AngularJS and webapi. The ApplicationUser model includes standard properties, IdentityRole, and a many-to-many relationship with a Company class. My goal is to utilize a form with ...

Integrate PHP code into a div using Javascript and Ajax without losing any previous inclusions

Having issues with my navigation bar and elements. <ul><li> The element in question is: <li> My elements are linked via ajax to a separate php function file: switch ($_GET['menu']){} The functions are separated on a php fi ...

Exploring ways to display all filtered chips in Angular

As a new developer working on an existing codebase, my current task involves displaying all the chips inside a card when a specific chip is selected from the Chip List. However, I'm struggling to modify the code to achieve this functionality. Any help ...

Issue with Moment.js formatting results in an 'invalid date' error

One issue I am encountering with my formatTime function using moment.js is that if the input number is NaN, moment.js outputs 'invalid date'. Does anyone know of a solution to fix this? $scope.formatTime = function(time) { if (time>24){ ...

When Hovering, Pseudo-class Cannot be Applied

In my design, I have an image overlaid with a Play icon. The concept is that when the user hovers over the image, the brightness of the image decreases and the Play icon is replaced with a Magnifying Glass icon. However, there seems to be a problem. When ...

Adjusting HTML5 drag height while resizing the window

Code conundrum: var dragHeight = window.innerHeight - parseInt(jQuery("#drag_area").css("margin-top")) - 5;. It sets the drag height based on browser size, but there's a glitch. If I start with a non-maximized browser and then maximize it, the drag he ...

Issue with Tailwind CSS classes not refreshing after initial React app compilation

Today, I took the leap and upgraded from tailwind v2 to v3 for my react app. The upgrade process went smoothly, but now I'm facing an issue where additional tailwind CSS classes added in development are not being picked up after recompilation followin ...

Tips for allowing divs to be dragged and resized within table cells and rows

UPDATE I believe that utilizing Jquery is the most appropriate solution for resolving my issue with the demo. Your assistance in making it work would be greatly appreciated. Thank you. My goal is to develop a scheduler application. https://i.sstatic.net ...

Can HTML5 be used to store IDs in PHP chat applications?

I'm in the process of developing a chat application with PHP. Everything is functioning properly, but I have encountered a potential loophole. I am implementing AJAX to fetch chat data as the user scrolls, similar to platforms like Facebook and Twitte ...

Adding a close button to the Angular UI Bootstrap Popover feature

My table has a popover for every cell, just like the following example: Here is the code for the popover: <td ng-repeat="i in c.installments" ng-class="{ 'first' : i.first, 'last' : i.last, 'advance' : i.advance.value > ...

How to prevent the back button from functioning in Android devices

It's so frustrating always hitting a dead end and I really need a clear answer. How can I disable the hardware back button on my app? And where should I input the code to disable it? I simply want users of my app to navigate within the app without usi ...

Obtain text nodes along with their corresponding parent elements in sequential order (more challenging than anticipated)

Let's take a look at this coding example: <div>Hello, my <span>name</span> is John</div> I am trying to extract both text nodes and their parent elements in sequential order. Here's how it should look: 1: "Hello, my ", ...

How to position slides in the center using react-slick

I'm having difficulty achieving vertical centering for an image in a react-slick carousel implementation. The issue can be seen here. https://codesandbox.io/s/react-slick-playground-o7dhn Here are the problems identified: Images are not centered: ...

Technique for ensuring consistent kerning across various browsers

Seeking advice on implementing kerning technique for a logotext in the <header>, ensuring cross-browser compatibility. Using this helpful tool created by Mr. Andrew (special thanks), I found a solution. Prior to the modification, the <header> ...

What is the best method for incorporating an Angular Component within a CSS grid layout?

I recently started learning Angular and am currently working on a project that requires the use of a CSS grid layout. However, I'm facing an issue with inserting a component inside a grid area specified by grid-area. My attempt to achieve this in app ...

The submit button must be double-clicked in Internet Explorer

The code below is used to submit a form and call a PHP script: <script> function handleBrowse() { $('#uploadedfile').click(); } function displayFilePath(obj) { document.getElementById('dummyFilePath').innerHTML = obj.val ...

Bullet-point Progress Indicator in Bootstrap

Seeking guidance on how to create a Bootstrap progress bar with dots incorporated, similar to the image linked below. Any tips or resources where I can learn more about this technique? https://i.stack.imgur.com/BF8RH.jpg .progress { width: 278px; he ...

Conceal language identifier upon initial page load in Angular

Using Angular-translate with partial-loader, I am looking to hide the translate key upon page load in app.js. var app = angular.module('myapp', [ 'ngRoute', 'appRoutes', 'pascalprecht.translate', ...

Utilizing JSON and Javascript to dynamically generate and populate interactive tables

Here's how I've structured my JSON data to define a table: var arrTable = [{"table": "tblConfig", "def": [{"column": "Property", "type": "TEXT NOT NULL"}, {"column": "Value", "type": "TEXT NOT NULL"}], "data": [{"Property ...