Ways to avoid text covering the button using CSS

Take a look at this image:

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

In the image, you can see that I have entered text in the input box. However, since there is also a button placed inside the box, the text gets hidden behind it.

Is there a way to prevent this issue? I want the button to stay in its place while ensuring that the text is not hidden and remains visible as more text is typed.

The HTML code used is:

<div class="form">
   <input type="text" placeholder="Subscribe & Get Notified" id="email_inp">
   <button style="outline: none;" class="btn-1 span btn-4 btn-4a icon-arrow-right" id="email_btn"><span></span></button>
</div>

The corresponding CSS code snippet for handling responsive design:

@media only screen and (max-width: 768px)
{
    input[type="text"]
    {
        font-family: "titillium_webregular", Arial, sans-serif;
        border: none;
        -webkit-border-radius: 3px 33px 33px 3px;
        border-radius: 10px 33px 33px 10px;
        color: rgba(85, 85, 85, 0.85);
        font-size: 1.1em;
        display: inline;
        padding: 19.7px 13px;
        background: #f5f5f5;
        outline: none;
        width: 93%;
        box-shadow: 0px 11px 34px #111;
        vertical-align: middle;
    }

    .btn-1
    {
        cursor: pointer;
        padding: 29px 29px;
        display: inline-block;
        position: relative;
        vertical-align: middle;
        margin-left: -67px;
        text-indent: -9999px;
        margin-top: 1px;
        outline: none;
        width: 20px;
        height: 14px;
        border:none;
    }
}

Your assistance on this matter would be greatly appreciated. Thank you in advance.

Answer №1

Here's a helpful tip for you: If you want to create some space next to the textbox, try adding padding to the right of it.

$(function(){
  $('#tbcss').val('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
});
#tbcss
   {
    padding-right: 40px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js"></script>
<input type="text" id="tbcss"/>

Answer №2

If you ask me, I would suggest incorporating your styling in a slightly different manner by also utilizing the .form CSS selector. One possible approach is to make use of flexbox:

.form {
  // Updated:
  display: flex;
  justify-content: space-between;
  // Retain your existing input CSS:
  -webkit-border-radius: 3px 33px 33px 3px;
  border-radius: 10px 33px 33px 10px;
  background: #f5f5f5;
  box-shadow: 0px 11px 34px #111;
  width: 93%;
}

input[type="text"] {
  // Updated:
  width: 100%;
  // Keep your existing styles excluding unnecessary ones:
  font-family: "titillium_webregular", Arial, sans-serif;
  color: rgba(85, 85, 85, 0.85);
  border: none;
  font-size: 1.1em;
  padding: 19.7px 13px;
  outline: none;
  vertical-align: middle;
}

.btn-1 {
  // New addition
  align-self: flex-end;
  // Maintain your previous styles without unnecessary declarations:
  cursor: pointer;
  padding: 29px 29px;
  text-indent: -9999px;
  margin-top: 1px;
  outline: none;
  width: 20px;
  height: 14px;
  border:none;
}

Incorporate webkit CSS properties if needed for compatibility with older browsers.

Answer №3

To avoid the image overlapping with the text, simply adjust the padding-right property of the input textfield.

Consider experimenting with a value like 40px or higher until you achieve the desired outcome; this should prevent the caret from extending beyond the button.

Answer №4

Simply include the following:

textarea[type="email"]
{
    margin-left:10%;
}

Answer №5

To solve this issue, simply include the CSS property "padding-right: 50px;" within the input text box class. Feel free to adjust the value of 50 to suit your specific requirements.

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

I desire for the iframe to only display under specific conditions

Currently, I have embedded an iframe onto a live website that I am still working on. You can find the iframe with results here. The issue is that I want to keep it hidden from the public eye. Therefore, I am exploring if there is a way to modify the link ...

I have a website hosted on Heroku and I am looking to add a blog feature to it. I initially experimented with Butter CMS, but I found it to be too pricey for my budget. Any suggestions on

I currently have a website running on Heroku with React on the front end and Node.Js on the back end. I want to incorporate a blog into the site, but after exploring ButterCMS, I found the pricing starting at $49 to be too steep for my budget. My goal is ...

Can anyone provide guidance on how to display all the value= options within an HTML (aspx) page?

I'm currently working with a .NET website that utilizes multiple webforms. Users input their data through a browser, and the submitted information is stored in a SQL Server database. However, I'm facing difficulty analyzing the data because ther ...

Is it possible to set all UI forms to a readonly/disable mode?

We have a specific requirement where, if the user's access level is set to "READ ONLY", all form input elements should be made readonly. Our coding approach involves using a template HTML that contains widgets which are referenced in the correspondin ...

Increase and decrease a counter in Javascript by clicking on two separate image tags, with increments and decrements between 1 and 10

Hello! I really appreciate your help. I am currently facing the following issue: <div id="thumb1"> <img class="img-responsive" id="prova" src="img/thumb-up-dark.png" alt=""> <div id="pinline">0</div> ...

The copyright (©) symbol is unresponsive to rotation

Why can't I rotate the © character? Am I missing something? .copy { font-size: 12px; font-family: Arial; writing-mode: vertical-rl; text-orientation: mixed; transform: rotate(180deg); } <span class="copy">&copy; This is not ...

The jQuery selector for input[type=text]:nth-child(2) is malfunctioning

I cannot utilize the ids or class names linked to the inputs because they are randomly generated on input. Here is how the render appears: <div class='dateSearch'> <label>Label 1</label> <input type='text' id=& ...

Sending JSON data to Python CGI script

I've successfully set up Apache2 and got Python running without any issues. However, I'm facing a problem with two pages - one is a Python Page and the other is an HTML page with JQuery. Could someone guide me on how to correctly make my ajax p ...

PHP unable to display echo containing line breaks and text in nested lists

Currently, I am tackling an issue with a multi-select list in my PHP pages. The problem arises when I select text and it appears in the wrong order due to the lack of wrap or text break on each item. Below is the PHP code I have written: <select id="SK ...

What's the reason for the element not inheriting margins from its parent?

I am facing an issue with centering an h1 header within a .banner element. When I try to apply margin to the header, it appears to indent not from the top border of the banner, but rather from the nav element located above the banner. After inspecting the ...

The radio button (with embedded controls) cannot be accessed using the tab key

My code is functioning perfectly as intended. All controls are accessible via the tab key or arrow keys, except for the second radio button labeled "No screening", which is never reached. Is there a simple solution to rectify this issue or should I consid ...

Ensuring a div remains perfectly centered

Currently, I am new to HTML and still in the process of learning. I am facing a challenge in centering a button within a div, and I have been using margins to position it. While this method works well when the window is fullscreen, the button's positi ...

Is the Data Being Saved: Verifying if the Value Has Been Altered?

Imagine your form containing numerous fields, where typically only 1 or 2 are modified and require saving. What approach do you take? Update the database with all values, regardless of any changes. Utilize form states to post back only the changed values ...

Step-by-step tutorial on designing an input slider to dynamically adjust the CSS :before linear-gradient values

Is there a way to achieve a gradient effect using pseudo-element :before on an image that can be customized by adjusting a slider input? I've been trying to implement this feature with the following code, but have not been successful so far. var ...

How can a JavaScript function be triggered by Flask without relying on any requests from the client-side?

I'm in the process of setting up a GUI server using Flask. The challenge I'm facing is integrating an API that triggers a function whenever there's a change in a specific Sqlite3 database. My goal is to dynamically update a table on the HTML ...

Exploring Selenium automation for optimal XPath identification

It's important for me to avoid using xpaths that rely on 'xpath position'. This is because if a new element is added to the page, the xpath may change and cause automation tests to fail. However, there are some web pages where the only xpat ...

Is the post secure if a HTTP web page sends an ajax request to a HTTPS url?

If I developed an HTML/jQuery widget to be embedded on third-party websites with users of very limited technical knowledge and potentially missing SSL certificates, would the information posted securely through AJAX Post to a secure URL remain protected? ...

adjustable canvas dimensions determined by chosen images

I would like to create a canvas image based on the selected image <canvas id="canvas" ></canvas> <input type="file" id="file-input"> Using JavaScript: $(function() { $('#file-input').change(function(e) { var file ...

Issues with Bootstrap Table Column Widths not Adjusting Properly

I am facing an issue with my Bootstrap 4 table where the fixed column widths specified in the header row are not being respected when the table is rendered. The Time column, for example, should only be 5% of the width but it is taking up more space than ex ...

Modifying the appearance of a text area through the adjustment of a single file

I am in the process of creating a unique code box style that I frequently update to keep it fresh. My goal is to have all the script external so that editing one file will automatically update all code boxes, eliminating the need to edit each one individua ...