What can I do to prevent the text from covering the icon?

My dilemma involves an HTML input alongside a Font Awesome icon. I'm striving to find a way to avoid restricting the amount of text a user can input while ensuring that the text doesn't overlap with .fa-comment-o. Any surplus text should simply be hidden instead of being cut-off abruptly. An analogy to this scenario is how Google handles text input without overlapping the microphone image or cutting off any excess text (Google employs an image, while I am utilizing a font icon).

Check out my fiddle here

<div id="container">
    <input id="input"  value="This is some really long text that will almost certainly not fit within the text box. What I'd like to do is not bleed beyond the comment icon."/>
    <i class="fa fa-comment-o"></i>
</div>


#input{
    width: 300px;
    height: 25px;
    margin-right: -30px;

}

.fa-comment-o{
  font-size: 16px;
  color: #333;
  cursor: pointer;
  right: 10px;

}

Answer №1

To make the necessary adjustments to your code, add padding-right:30px. It's important to note that increasing the padding will also increase the width.

#input{
    width: 270px;
    height: 25px;
    margin-right: -30px;
    padding-right:30px;

}

View the updated version on FIDDLE

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

Floating elements within scrolling loading

I've been trying to figure out how to add a loading scroll feature to my webpage, but I'm running into issues with the div not displaying correctly. Instead of loading underneath the scroll, the content pops up on the side as shown here when scro ...

Response received from the server

I am looking to display server response error messages within a form after submission. By using the following code in my JavaScript, I am able to retrieve the error message: .error(function (data, status, header, config) { $scope.postDataSuccessfully ...

Reordering Divs in Bootstrap 3 Specifically for Small Screens

Just getting started with my first responsive design project, and I'm wondering if it's possible to achieve something like this using Bootstrap 3. The goal is to switch from the current layout: https://i.stack.imgur.com/lABXp.jpg To https://i. ...

Can a gradient box arrow be created using CSS 3?

Check out the following link to see a green box with a left-pointing arrow that floats: Is it achievable using solely CSS3? Can the arrow shape and gradient be created to appear in both the box and the arrow? If yes, how would you go about achieving this ...

Accessing a variable from another HTML using JavaScript

I'm currently attempting to access a variable from another HTML file using JS. Specifically, I have a file (file1.htm) that opens a dialog box, and I want to send the information of the selected file to another file (file2.htm) in order to modify a v ...

Get Code Now Button

I operate a website dedicated to Amazon reviews, and I am in need of a button that can request a code from a text file uploaded by the seller. My question is how can this be achieved using HTML? I have been experimenting with this sample: <!-- Butt ...

Connected selection menu

I have noticed several discussions on this topic, but many of them rely on JavaScript or focus solely on a standard drop-down list. I have developed a PHP function that generates drop-down menus based on select queries in my database. Currently, this part ...

Checkbox offering a tri-state option

Seeking help on creating a checkbox with three states. I have implemented a method to toggle between these states upon clicking. However, the issue is that this method is only triggered after the HTML changes. As a result, the checkbox's navigation be ...

Looking to use Jquery to translate an image both on and off the screen with full width and height?

Imagine a scenario where a full-screen image remains hidden upon page load. When a user clicks a link, the image smoothly slides up from the bottom of the page. Upon clicking the image, it should smoothly move off the page as if it were being translated do ...

Collapsed Bootstrap navigation bar on mobile devices

Hello everyone, I am currently using the latest version of Bootstrap for my website. However, I have encountered an issue where the navigation collapses on mobile view. Could anyone provide assistance? Website: Below is a snippet of my HTML code: <he ...

Is it possible that my PHP script will not accept my POST request if I initially

Recently, I developed a dynamic signature generator for my online game. To create your own signature, you can manually access it via I attempted to simplify the process by creating a userbox where users don't have to visit and edit it. My goa ...

Troubleshooting resizing images in React using Material UI's useStyles

When attempting to resize an image using React, I am encountering a problem where adjusting the height and width of the tag with useStyles does not reduce the size of the image but instead moves it around on the page. Here is the code snippet: import { ma ...

search engine optimized for easy input via keyboard

I have successfully incorporated AJAX search functionality into my project, inspired by this example here. The unique feature of this implementation is the ability to navigate through search results using the TAB key. The structure of my search results tab ...

How to make Bootstrap 4 multiple child divs of column height fill to 100%

Is there a more graceful way to ensure that the div with id "second" fits inside its parent container and does not overflow when the h-100 class is applied in Bootstrap? Currently, I have used a hack by adding overflow:hidden to the parent container of the ...

Update the class of the panel immediately prior to a click event

Is it possible to change the class before the animation starts or when opening/closing the panel? Currently, the class only changes after the animation has finished and the panel is already open or closed. Here is an example: http://jsfiddle.net/0b9jppve/ ...

What is the best method to exclude the <a> tag when displaying content in HTML?

Is there a way to hide the link within an a tag when printing? .p { display: none; } @media print { .p { display: initial; } .np { display: none; } } <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css ...

How to perfectly center a text box in HTML

UPDATE: I have included the relevant JavaScript code. Essentially, a text box appears when a checkbox is clicked, but I want the text box to be centered on the page. I am attempting to center align a text box on the page, but I am struggling to achieve th ...

Position the menu links in different alignments - some to the right and others to the

I have created a horizontal menu using HTML and CSS. Currently, the links (boxes) are displayed from left to right, floated to the left of the page. However, I am looking for a way to make one of the links (boxes) float to the right side of the page. I at ...

Leveraging external files with Django template referencing

Having trouble including external JavaScript and CSS files in the head tags of my Django template. They only seem to work when placed before the closing body tag. Any idea why this is happening? Another issue I'm facing is that when using inheritance, ...

Close button located in the upper-right corner is partially cut off

My challenge involves placing a close button on the top right corner of a #main div that contains an image of varying or larger size. I need the close button to slightly protrude outside the div using negative margins. The issue is that when I use overflow ...