Create a visually appealing rectangular box with written content inside

Can you assist with designing a text box similar to this image: https://i.sstatic.net/K5zw8.png

I would like the login label inside the border of the textbox. Any guidance on how to achieve this using Bootstrap and CSS would be greatly appreciated, thank you!

Answer №1

Check out this helpful answer for a solution!

View Live Jsfiddle

.sample-form {
  margin: 15px 0;
}

.sample-form .form-group {
  position: relative;
}

.sample-form .form-group label {
  position: absolute;
  top: -15px;
  left: 15px;
  background-color: #ffffff;
  margin: 0;
  padding: 2px 5px;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>


<div class="container">
 <form class="sample-form">
   <div class="form-group">
    <label for="usr">Name:</label>
    <input type="text" class="form-control" id="usr">
  </div>
 </form>
</div>

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

Add a border to the navigation bar item to indicate the current page being displayed

This section shows the current navigation bar item https://i.sstatic.net/6RAGJ.png This is the desired outcome when clicking on the tab https://i.sstatic.net/8nFeB.png Uncertain about the best approach for achieving this. I have attempted to submit a val ...

How can the $spacer variable in Bootstrap be modified?

My attempt to adjust the $spacer variable in SASS to increase margins seems to be failing. Here is my code: @import url(../node_modules/bootstrap/scss/_functions.scss); @import url(../node_modules/bootstrap/scss/_variables.scss); @import url(../node_module ...

Guide to creating a distortion-free layout with Bootstrap 4

I am in need of creating a design layout using Bootstrap 4 with the following specifications: https://i.sstatic.net/JeUHh.png Here is my code : <div class="row"> <div class="col-md-7"> A </div> <div class="col-md-5"> <div ...

Having trouble accessing properties in AngularJS

This is my code snippet: app.controller('userController', function UserController($scope, userFactory) { $scope.users = []; $scope.user = { items : [] }; $scope.editMode = false; $scope.addItem = function () { $scope.use ...

Python is experiencing difficulties with copying xpath elements

I attempted to utilize some Python code to access Twitter and retrieve the "Happening now" text. Unfortunately, it was unsuccessful. import webbrowser print("Visiting Twitter.com...") webbrowser.get('C:/Program Files (x86)/Google/Chrome/Application/c ...

Initializing trans tags within Djangocms-text-ckeditor

I have encountered a problem while using the djangocms-text-ckeditor plugin to insert text into my pages, particularly related to translations. Even though I have included load i18n at the beginning of my code, when I switch to the source and directly ent ...

Elevation on Tab button from the upper side

On my website, I have a large form where pressing the tab key switches between input fields. The inputs will also jump to the top if we reach the bottom of the form. The issue is that I have a fixed header at the top, covering the first 60px. Is there a w ...

Guide to verify the user selection within a select form

Here is a form with a select field: <form method="post" name="posting_txt" onSubmit="return blank_post_check();" id="post_txt"> <select style="background: transparent; border-bottom:5px;" name="subname" class="required"> ...

The image filter plugin is functioning properly in one project, however, it is not working in

After successfully using a plugin from w3schools to filter elements in one project, I encountered an issue when attempting to implement it in another project. Here is the link to the problematic code pen: https://codepen.io/zakero/pen/mZYBPz If anyone ca ...

checkbox-activated navigation bar

Struggling to implement a Nav-drawer that should open when a checkbox is selected, everything seems to be set up correctly but the issue arises when it comes to actually opening it. Here is the code snippet: <div class="leftside"> <input typ ...

Issues with Iframe { height:70%;} in Internet Explorer 8 and Firefox causing display problems

In my website's design, I have a div structure with an iframe to load pages. The header remains at the top seamlessly The footer stays at the bottom perfectly The content is positioned in the middle flawlessly However, the iframe does not stret ...

Issue with Google Maps iFrame not loading when utilizing JavaScript variables in the "src" attribute

Currently, I am facing an issue with utilizing JavaScript variables containing GPS latitude and longitude values in the "src" attribute of an iFrame in an HTML file for displaying image EXIF data on a Google Maps iFrame. When I hardcode specific latitude ...

Creating a personalized pop-up container similar to the style seen on YouTube

I am looking to create a popup window similar to the YouTube share feature where it sticks next to a button. I have tried using Bootstrap modal, but it opens in the middle of the screen. I want the popup to appear around the button when the YouTube share b ...

Is it possible to track keystrokes without the use of text input fields?

For various unimportant reasons, I need to use JavaScript to create links instead of using the anchor tag. I want the behavior to mimic the anchor tag, allowing users to open a link in a new tab when holding down the Ctrl key or in a new window when holdin ...

What is the best approach to obtain an inventory of inputs from a particular viewpoint?

I am facing an issue where I have a list of products that require the quantities to be returned along with the reason for return. However, I cannot modify the referenced model as it has an impact on multiple values. Can someone guide me on how to retrieve ...

Tips for incorporating a CSS class representing an image into a CodeIgniter form submission

<?php $data = array( 'class' => "btn btn-primary btn-lg", 'name' => 'report' ); echo '<span class="glyphicon glyphicon-exclamation-sign"></span> '; echo form_subm ...

Dropdownmenu without borders

I'm having an issue with the dropdown menu on my website - there are no borders showing. I've tried fixing it myself with no luck, so I could really use some help. As a beginner in web development, I don't have much knowledge about these thi ...

Having trouble resolving 'primeng/components/utils/ObjectUtils'?

I recently upgraded my project from Angular 4 to Angular 6 and everything was running smoothly on localhost. However, during the AOT-build process, I encountered the following error: ERROR in ./aot/app/home/accountant/customercost-form.component.ngfactory. ...

Sending user input from search component to main App.js in React

I'm currently working on an app that searches a Movies database API. I have a main fetch function in App.js, and in tutorials, people are using a search bar within this main APP component. I'm wondering if it would be better to create a separate ...

Is the form data in AngularJS not submitting correctly?

Why is my HTML form data not being submitted using POST method? HTML View Page:- <div class="col-sm-12"> <div class="card-box"> <form class="form-inline" name="addstock" ng-submit="saveStockPurchaseInvoice()"> <h ...