The input field will display a border when it is actively selected

I am currently designing a form where the label should be positioned on the top border line of the text box.

[![enter image description here][1]][1]

Here is the code snippet:


   <div class="container">
    <div class="row">
        <div class="page-account-box">
            <div class="col-md-9 mx-auto">
                <div class="account-box">
                    <div class="picture_account">
                        <img src="~/images/d2.jpg" class="imgFormat " />
                    </div>

                    <div class="account-box-content mt-4">
                        <h4>Register</h4>
                        <form method="post" class="form-account">
                            <div class="row pt-3 ">
                                <div class="col-6">
                                    <div class="newinput">
                                        <label>Name </label>
                                        <div class="col-12 ">
                                            <input type="text" id="FirstName" class="w-100">
                                        </div>

                                    </div>
                                </div>
                                <div class="col-6">
                                    <div class="newinput">
                                        <label>Lastname </label>
                                        <div class="col-12">
                                            <input type="text" id="LastName" class="w-100">
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="row pt-3 ">
                                <div class="col-12">
                                    <div class="newinput">
                                        <label>Email </label>
                                        <div class="col-12">
                                            <input type="email" id="Email" class="w-100">
                                        </div>
                                    </div >
                                </div>
                            </div>                                                             
                        </form>
                    </div>

                </div>
            </div>
        </div>
    </div>
   </div>

And here is the CSS:


   .page-account-box {
   width: 100%;
    margin-top: 70px;
  }

.page-account-box  .account-box {
    width: 100%;
    height: auto;
    padding: 0;
    border: 1px solid #e2efef;
    -webkit-box-shadow: 0 12px 12px 0 hsla(0,0%,70.6%,.11);
    box-shadow: 0 15px 23px 0 hsla(0, 0%, 71%, 0.29);
    position: relative;
    margin: 70px auto 30px;
    display: flex;
    background: #fff;
    border-radius: 20px;
   }
   .page-account-box .account-box .account-box-content {
        min-height: 50%;
        padding: 15px 20px;
        border-radius: 20px;
        border: 2px solid black;
        width: 100%;
    }
 .form-account {
padding:0px;
 margin:0px;
 }
  .page-account-box .account-box .account-box-content .form-account .newinput {
  padding: 5px;
  border: 2px solid;
  margin: 0px;
 height:40px;
}
   .page-account-box .account-box .account-box-content .form-account .newinput input {
border: none;

  }

    .page-account-box .account-box .account-box-content .form-account .newinput input:focus {
        background-color: red;           
        border: none;
        border-color:white;
    }

 .page-account-box .account-box .account-box-content .form-account .newinput label {
  position: absolute;
  top: -13px;
  right: 25px;
  background-color: white;
 }

Everything is working fine except that the input box still has a black solid border even when it's focused. I have set the border to none on focus, but it's not working. How can I remove the border of the input box?

https://i.sstatic.net/BZoov.jpg

Answer №1

The code is functional and correct.

.page-account-box {
  width: 100%;
  margin-top: 70px;
}

.page-account-box .account-box {
  width: 100%;
  height: auto;
  padding: 0;
  border: 1px solid #e2efef;
  -webkit-box-shadow: 0 12px 12px 0 hsla(0, 0%, 70.6%, .11);
  box-shadow: 0 15px 23px 0 hsla(0, 0%, 71%, 0.29);
  position: relative;
  margin: 70px auto 30px;
  display: flex;
  background: #fff;
  border-radius: 20px;
}

.page-account-box .account-box .account-box-content {
  min-height: 50%;
  padding: 15px 20px;
  border-radius: 20px;
  border: 2px solid black;
  width: 100%;
}

.form-account {
  padding: 0px;
  margin: 0px;
}

.page-account-box .account-box .account-box-content .form-account .newinput {
  padding: 5px;
  border: 2px solid;
  margin: 0px;
  height: 40px;
}

.page-account-box .account-box .account-box-content .form-account .newinput input {
  border: none;
}

.page-account-box .account-box .account-box-content .form-account .newinput input:focus {
  background-color: red;
  border: none;
  border-color: white;
}

.page-account-box .account-box .account-box-content .form-account .newinput label {
  position: absolute;
  top: -13px;
  right: 25px;
  background-color: white;
}

textarea:focus,
input:focus {
  outline: none;
}
<div class="container">
  <div class="row">
    <div class="page-account-box">
      <div class="col-md-9 mx-auto">
        <div class="account-box">
          <div class="picture_account">
            <img src="~/images/d2.jpg" class="imgFormat " />
          </div>

          <div class="account-box-content mt-4">
            <h4>Register</h4>
            <form method="post" class="form-account">
              <div class="row pt-3 ">
                <div class="col-6">
                  <div class="newinput">
                    <label>Name </label>
                    <div class="col-12 ">
                      <input type="text" id="FirstName" class="w-100">
                    </div>

                  </div>
                </div>
                <div class="col-6">
                  <div class="newinput">
                    <label>Lastname </label>
                    <div class="col-12">
                      <input type="text" id="LastName" class="w-100">
                    </div>
                  </div>
                </div>
              </div>

              <div class="row pt-3 ">
                <div class="col-12">
                  <div class="newinput">
                    <label>Email </label>
                    <div class="col-12">
                      <input type="email" id="Email" class="w-100">
                    </div>
                  </div>
                </div>

Answer №2

It is necessary to remove the outline when the input is in focus

Here is an example of how to do it:

input:focus {
   outline: 0;
}

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

Struggling to Make Text Overlay Transparent and Slide Only to the Right

Can someone help me make my image have an opaque overlay with text that slides only right when hovered over? Currently, it's sliding both right and up. Any suggestions on how to fix this issue would be greatly appreciated. Thank you. html, body{ ...

Exploring the implementation of Javascript, HTML, PHP, and Ajax in programming

<div class="navigation"> <a class="prev" href="index.php?month=__prev_month__" onclick="$('#calendar').load('index.php?month=__prev_month__&_r=' + Math.random()); return false;"></a> <!-- <div class="title" & ...

What is the best way to increase padding in a Vuetify view element?

I have been attempting to increase the padding of my view by utilizing the "px-5" class on the container within the view. However, I am struggling to achieve the desired amount of padding. What I am aiming for is padding similar to what is shown in this sc ...

How come the font size doesn't transfer from the div element to the table element?

I am experiencing an issue with my document presentation. The document is simple and includes HTML and CSS code as well as some text content. When I render the document, I notice that the table element does not inherit the font size from its parent div, un ...

Tips for utilizing innerHeight for a div during both window loading and resizing tasks?

I'm currently working on calculating the top/bottom padding of a div (.content) based on its height, and updating it upon loading and resizing the window. The goal is to have it centered nicely next to another div (.character) positioned beside it. I ...

Switch up the styling of a component by updating its properties with a switch statement

Although there is a similar question, my query has a unique requirement. I have defined the common styles for my button and implemented a function using a switch statement with different properties for various buttons across different pages. However, for ...

JavaScript formula for calculating dates together

I'm currently developing a PHP program for generating invoices. I'm implementing a datetimepicker to select the invoice generation date and due date. Now, I need the due date field to be automatically populated by adding a specific value to the i ...

Error TS2339: The 'selectpicker' property is not found on the 'JQuery<HTMLElement>' type

Recently, I integrated the amazing bootstrap-select Successfully imported bootstrap-select into my project with the following: <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstra ...

Are you looking to analyze inputs and tally up any duplicates?

I am working on a form that requires users to input up to 20 1-4 character codes. My goal is to count each code entered and present the output in the following format: AB //entered once EFOO //entered once AACC x 2 //because AACC was entered twice into fo ...

Using HTML code to incorporate one HTML file into another's structure

As a skilled programmer, I understand the importance of code reusability. Despite being new to HTML and CSS programming, I often find myself writing repetitive code in one HTML file. Is there a way to avoid this redundancy? Can functions be utilized in H ...

Utilizing a JavaScript variable within a jQuery function as an attribute

var image = "path.png"; Is it possible to include the 'image' variable in the jQuery function like this? $('#mapfoto').prepend('<img id="theImg" src="http://path.gr/" + image />'); ...

What is the best way to transfer the text from an input field into a paragraph when a button is

For a school project, I am developing a website focused on time management. My goal is to create an input text box that, when the "add task" button is clicked, transfers the text inside it to a paragraph or p2 element and then moves the input field down. ...

Positioning a div in the center horizontally may result in content with a large explicit width being

I am in search of a solution to horizontally center content on a webpage, regardless of whether or not it has a defined width. After referencing a Stack Overflow question on centering a div block without the width, I found a great method that works well w ...

showcase every value upon submission in the form with options to edit and delete

Is it possible to display all values submitted in a form with edit and delete buttons? Currently, only one value is being displayed at a time. Whenever a new value is displayed, it replaces the old one. How can this be fixed? You can fin ...

Slideshow box with images aligned perfectly

I have designed a container with images, but my goal is to: either show the images inline or stack them on top of each other, and then be able to navigate through them using jQuery. I attempted absolute positioning on both .box and .box img, as well as u ...

Cropping and resizing images

Within my angular application, I have successfully implemented image upload and preview functionality using the following code: HTML: <input type='file' (change)="readUrl($event)"> <img [src]="url"> TS: readUrl(event:any) { if ...

Choose multiple options, with a maximum limit of 2 selections

I am currently working with a multiselect feature for various subjects. I would like to limit the selection to a maximum of 2 options and disable the rest. Additionally, if a user deselects an option, it should become available again for selection. <se ...

What is the best technique to incorporate dark/light mode in Bootstrap 5?

Is it best to introduce themes such as dark and light themes in Bootstrap 5 using CSS/SCSS, JavaScript, or a combination of both? Should we create a separate CSS file like dark.css to overwrite classes? Or should we use JavaScript to switch classes like ...

Challenges arising when transferring data from Django to HTML

I am trying to calculate the sum of elements in lista[] which consists of decimal numbers, but I keep getting this error message: lista[] is composed of decimal numbers ValueError at / argument must be a sequence of length 3 This is my code : views.py ...

Crafting an innovative horizontal CSS spotlight using conic-gradient styling

Seeking advice: I need to implement three spotlights on a webpage One shining directly downwards One angled from the left to the upper-top One angled from the right to the upper-top I managed to create a vertical spotlight using CSS conic-gradient, but I ...