<button> in line with <fieldset>

Good morning,

I have been attempting to align the <button> element relative to the <fieldset>, but so far, I've only been able to center it using margin:0 auto;.

Is it possible to position the <button> outside the <fieldset> in the center of the right side border, as shown in the image below?

Thank you in advance for any suggestions.

https://i.sstatic.net/nd3dJ.png

var app=angular.module('myApp',[]);

app.controller('inspectionController', function ($scope, $http) {
$scope.choiceSet = {choices: []};
    $scope.quest = {};

    $scope.choiceSet.choices = [];
    $scope.addNewChoice = function () {
        $scope.choiceSet.choices.push('');
    };

    $scope.removeChoice = function (z) {
        var lastItem = $scope.choiceSet.choices.length - 1;
        $scope.choiceSet.choices.splice(z,1);
    };
    });
/* Custom CSS */

   
textarea {
  border:2px solid #9C9C9C;
  display: block;
  margin:auto;
  position:relative;
}

textarea:focus {
  outline: none !important;
  border-color: #719ECE;
  box-shadow: 0 0 10px #719ECE;
  border:2px solid #00C4B0;
}

.btn-btn-info {
  -webkit-border-radius: 9;
  -moz-border-radius: 9;
  border-radius: 9px;
  font-family: Arial;
  color: #ffffff;
  font-size: 15px;
  background: #2be632;
  padding: 8px 12px 8px 12px;
  text-decoration: none;
  display:table;
  margin: 0 auto;
}

.btn-btn-info:hover {
  background: #74f278;
  text-decoration: none;
}

.btn-btn-default-btn-sm {
  -webkit-border-radius: 9;
  -moz-border-radius: 9;
  border-radius: 5px;
  font-family: Arial;
  color: #ffffff;
  font-size: 12px;
  background: #e62b2b;
  padding: 3px 6px 3px 6px;
  text-decoration: none;
  display:table;
  margin:0 auto;
}

.btn-btn-default-btn-sm:hover {
  background: #e87474;
  text-decoration: none;
}
<!DOCTYPE html>
<!--[if lt IE 7]>      <html lang="en" ng-app="myApp" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html lang="en" ng-app="myApp" class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html lang="en" ng-app="myApp" class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html lang="en" ng-app="myApp" class="no-js"> <!--<![endif]-->
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Front-end developer task</title>
  <meta name="description" content="">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="bower_components/html5-boilerplate/dist/css/normalize.css">
  <link rel="stylesheet" href="bower_components/html5-boilerplate/dist/css/main.css">
  <link rel="stylesheet" href="app.css">
  <script src="bower_components/html5-boilerplate/dist/js/vendor/modernizr-2.8.3.min.js"></script>
  <script data-require="<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3958575e4c55584b534a7908170d">[email protected]</a>" data-semver="1.4.9" src="https://code.angularjs.org/1.4.9/angular.min.js"></script>
</head>

<body ng-app="myApp" ng-controller="inspectionController">
  

  <!--[if lt IE 7]>
      <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
  <![endif]-->


  <!-- In production use:
  <script src="//ajax.googleapis.com/ajax/libs/angularjs/x.x.x/angular.min.js"></script>
  -->
  <script src="bower_components/angular/angular.js"></script>
  <script src="bower_components/angular-route/angular-route.js"></script>
  <script src="app.js"></script>
   
</br>
    <div class="col-sm-10">
      <input type="button" class="btn-btn-info" ng-click="addNewChoice()" value="ADD USER"></br>
      <div class="col-sm-4">
      <fieldset data-ng-repeat="field in choiceSet.choices track by $index">
      <button type="button" class="btn-btn-default-btn-sm" ng-click="removeChoice($index)">X</button>
      <textarea  class="input" rows="2" cols="30" placeholder="Describe User" ng-model=" choiceSet.choices[$index]"></textarea> </br>
      </fieldset>
      </div>
    </div>

</body>
</html>

Answer №1

Position the button below the text area

Implement CSS styling as shown below

textarea {
  border: 2px solid #9C9C9C;
  display: inline-block;
  margin: auto;
  position: relative;
  vertical-align: middle;
}

button {
  display: inline-block !important;
}

fieldset {
  text-align: center;
}

Code snippet provided below

var app = angular.module('myApp', []);

app.controller('inspectionController', function($scope, $http) {
  $scope.choiceSet = {
    choices: []
  };
  $scope.quest = {};

  $scope.choiceSet.choices = [];
  $scope.addNewChoice = function() {
    $scope.choiceSet.choices.push('');
  };

  $scope.removeChoice = function(z) {
    var lastItem = $scope.choiceSet.choices.length - 1;
    $scope.choiceSet.choices.splice(z, 1);
  };
});
/* Custom CSS styles */

textarea {
  border: 2px solid #9C9C9C;
  display: inline-block;
  margin: auto;
  position: relative;
  vertical-align: middle;
}

button {
  display: inline-block !important;
}

fieldset {
  text-align: center;
}

textarea:focus {
  outline: none !important;
  border-color: #719ECE;
  box-shadow: 0 0 10px #719ECE;
  border: 2px solid #00C4B0;
}

.btn-btn-info {
  -webkit-border-radius: 9;
  -moz-border-radius: 9;
  border-radius: 9px;
  font-family: Arial;
  color: #ffffff;
  font-size: 15px;
  background: #2be632;
  padding: 8px 12px 8px 12px;
  text-decoration: none;
  display: table;
  margin: 0 auto;
}

.btn-btn-info:hover {
  background: #74f278;
  text-decoration: none;
}

.btn-btn-default-btn-sm {
  -webkit-border-radius: 9;
  -moz-border-radius: 9;
  border-radius: 5px;
  font-family: Arial;
  color: #ffffff;
  font-size: 12px;
  background: #e62b2b;
  padding: 3px 6px 3px 6px;
  text-decoration: none;
  display: table;
  margin: 0 auto;
}

.btn-btn-default-btn-sm:hover {
  background: #e87474;
  text-decoration: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<!DOCTYPE html>
<html lang="en" ng-app="myApp" class="no-js">

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Front-end developer task</title>
  <meta name="description" content="">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="bower_components/html5-boilerplate/dist/css/normalize.css">
  <link rel="stylesheet" href="bower_components/html5-boilerplate/dist/css/main.css">
  <link rel="stylesheet" href="app.css">
  <script src="bower_components/html5-boilerplate/dist/js/vendor/modernizr-2.8.3.min.js"></script>
  <script data-require="<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="47262920322b26352d3407766973"></a>" data-semver="1.4.9" src="https://code.angularjs.org/1.4.9/angular.min.js"></script>
</head>

<body ng-app="myApp" ng-controller="inspectionController">


  <!--[if lt IE 7]>
      <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
  <![endif]-->


  <!-- In production use:
  <script src="//ajax.googleapis.com/ajax/libs/angularjs/x.x.x/angular.min.js"></script>
  -->
  <script src="bower_components/angular/angular.js"></script>
  <script src="bower_components/angular-route/angular-route.js"></script>
  <script src="app.js"></script>

  </br>
  <div class="col-sm-10">
    <input type="button" class="btn-btn-info" ng-click="addNewChoice()" value="ADD USER"></br>
    <div class="col-sm-4">
      <fieldset data-ng-repeat="field in choiceSet.choices track by $index">

        <textarea class="input" rows="2" cols="30" placeholder="Describe User" ng-model=" choiceSet.choices[$index]"></textarea> <button type="button" class="btn-btn-default-btn-sm" ng-click="removeChoice($index)">X</button></br>
      </fieldset>
    </div>
  </div>

</body>

</html>

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 to Use PHP to Submit Form Information

I am a beginner in PHP and I need help with sending form details to an email address. I have tried looking for solutions online but I keep running into the same issue - when I submit the form, it downloads the PHP file instead of sending an email. Below i ...

What is the best way to generate an embedded HTML template with <script type="text/template"> using jQuery?

I am interested in creating HTML templates that can be accessed from jQuery using script tags and then displayed using jQuery. <script type="text/template"> <div id="new-post"> <form> <label>Post Title</label> ...

ReactJS encountering an invalid dropzone element

Encountering the error "invalid dropzone element". I added var Dropzone = require('react-dropzone'); to my webpack.config.js file in hopes of activating the Dropzone element. This is what is included in my JavaScript file, copied from a Gith ...

Is there a way to prevent the splash screen from appearing every time I navigate using a navbar link in a single page application (SPA)?

Recently, I came across this tutorial and followed it diligently. Everything seemed to be working perfectly until I encountered an issue with my navbar links. Each time I clicked on a link, the splash screen appeared, refreshing the page without directing ...

What is the best way to achieve consistent appearance across all browsers and various screen sizes?

I have implemented owl carousel on my website for sliding the container. While the slider functions correctly, I encounter issues when minimizing the screen or viewing it on different monitors or browsers. The problem lies in the fact that the code is not ...

I am attempting to link a child object literal with a parent object literal

In a practical sense, I believe I can provide a clearer description of the problem I am encountering. What I am trying to achieve is linking a child entity to its parent. In my current scenario, I have two models: owner and property. An owner can have mult ...

CSS - Issue with a blurred div nested inside another blurred div

I'm facing an issue where I can't have a blurred element inside another blurred element. Currently, I have a header with backdrop-filter: blur(3px); and a div within it with a more intense background blur of backdrop-filter: blur(50px);. However, ...

Tips for achieving seamless scrolling with the combination of javascript and css

Looking for a solution to achieve smooth scrolling on an HTML page without using the #id_name to scroll to a specific div. Instead, I want to scroll to a particular point, such as having a button that scrolls down the webpage smoothly by 250px when press ...

Troubles encountered with webserver authentication while attempting to view webserver material using UWP WebView

In my IoT Core app development project, I am faced with the challenge of displaying webpages from a remote Apache webserver. The WebView class method .Navigate() has been effective for accessing non-protected pages, but I am struggling to figure out how to ...

Top solution for resolving TypeScript error - property not found on type

Encountering an issue when defining a custom property on an array or object in typescript, leading to the error message: "Property x does not exist on type Object (or type Array)" For instance, working with typescript in Angular and having a defined scop ...

Entwine words around an immovable partition

Is it possible to create an HTML element that remains fixed in place even as the content on the webpage changes, with everything else adjusting around it? I am looking to add a continuous line that spans across a dynamic webpage. No matter how much conten ...

Tips for positioning a Navbar in the middle of the screen at 90% width

I am struggling to center the navbar as a whole, rather than just the contents within it. Below is the CSS and HTML for my navbar. .navbar { border-radius: 10px 10px 30px 30px; background: #3CE18F; overflow: visible; position: fixed; bottom: ...

Clicking will cause my background content to blur

Is there a way to implement a menu button that, when clicked, reveals a menu with blurred content in the background? And when clicked again, the content returns to normal? Here's the current HTML structure: <div class="menu"> <div class=" ...

Looking for a JavaScript or jQuery library that can effectively translate XPath into a user-friendly CSS3 format for easy selection in

Is there a way to transform an XPath expression such as /html/body/div[3]/ul/li[1]/a[5] html > body > div[3] > ul > li[1] > a[5] I am aware that CSS3 selectors do not support indexing....what alternative approach should I take? ...

Ways to enable users to add or modify spry widgets

Is there a way to make it easier for users to edit spry accordions/tabbed panels in a navigation tool for locating points in PDFs? The PDFs are updated regularly, so the navigation will need frequent updates. The users who will be maintaining this tool h ...

Guide on making a dynamic circular spinning menu bar

I am struggling to create a circular spinning navigation bar using CSS3 and HTML. How can I achieve this effect? I have attached a picture from an old game that showcases the animation I am aiming for. When the active circle is selected, the corresponding ...

Is there a way to adjust the height of one div based on the height of another div in Bootstrap?

I am experimenting with a Bootstrap example featuring a table in the left column and 4 columns in 2 rows in the right column. Check out the code below: <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css ...

Animating a spinning SVG path around its center within a larger rectangular box

Is there a way to rotate a smaller SVG path within a larger rectangle around its own center? The current code rotates the entire space. <animateTransform attributeType="xml" attributeName="transform" type="rotat ...

What are the steps to create a dynamic background color effect for an element?

I'm having trouble cycling through different colors or background images. The code I tried only runs once and doesn't loop as expected. .landing-background { background-color: red; -webkit-animation-name: example; /* Chrome, Safari, Oper ...

Is there a way to monitor song listens in a playlist using HTML5, Jplayer, and mysql?

In the process of creating a personalized player with 3 different playlists, the user will be able to choose which playlist they would like to listen to. I am seeking a way to track how many times each song in the selected playlist has been played. Is it ...