What is the best way to adjust a <textarea> to fit a multi-column layout?

Here's a cool way to display text in columns:

<div class="content-box" style="column-width: 8em">
  <p>blah blah...</p>
  <p>blah blah...</p>
  <p>blah blah...</p>
</div>

However, when it comes to the textarea, it doesn't align with the column-wise layout like the rest of the text does:

<div class="content-box" style="column-width: 8em">
  <p>blah blah...</p>
  <textarea rows="100"></textarea>
  <p>blah blah...</p>
  <p>blah blah...</p>
</div>

I'm looking for a way to include a textarea that flows seamlessly with the text across columns. It should resemble the surrounding text but be editable. Is there a solution for this?

My goal is to create a mad-libs application with a multi-column text layout (similar to a newspaper) where certain sections are fill-in-the-blank and editable. The editable areas might be lengthy and I'd like them to smoothly transition into the next column if needed, just like regular text.

Answer №1

A textarea won't have that functionality, but a contenteditable element will allow for editing.

div[contenteditable] {
  outline: none;
}
<div class="content-box" style="column-width: 8em">
  <p>blah blah...</p>
  <div contenteditable>
  blah edit<br>
  blah edit<br>
  blah edit<br>
  blah edit<br>
  blah edit<br>
  blah edit<br>
  blah edit<br>
  blah edit<br>
  blah edit<br>
  blah edit<br>
  blah edit<br>
  </div>
  <p>blah blah...</p>
  <p>blah blah...</p>
</div>

Answer №2

It is unlikely that you will be able to achieve this functionality using a textarea element. The limitations of browser defaults may restrict the flexibility required for your needs.

One alternative approach could involve creating a custom simulation of a textarea using CSS and manually handling keyboard and mouse events. However, implementing this solution may require a significant amount of effort on your part.

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

When the text starts to overlap the column completely at approximately 700 pixels wide

Previously, everything was working fine until it suddenly broke. The column system switches to a 100% width single column at 1500px, but for some reason, the text overflows off the screen around 700px and I can't figure out why. The text at the bottom ...

Utilizing checkboxes to dictate PHP and MySQL queries

Seeking assistance with MySQL, jquery and PHP. Here is the code provided: HTML <label class="checkbox"><input type="checkbox" name="code_site1" class="code_site1" checked="checked">Code 1</label> <label class="checkbox"><input ...

Tips for switching a group of buttons within a userscript by clicking a single button?

Apologies if my wording is not clear, allow me to clarify. I am in the process of developing a userscript that will display a set of buttons below a main button when clicked. These additional buttons will serve different functions and should disappear whe ...

Unable to modify the hover color on the image or icon

After creating a circle icon with an image in the center, I wanted to make the image change colors on hover. The main focus of the icon is the circle itself. In my attempt to achieve this effect, I included the following code for the circle icon: .circle- ...

The div is lacking in height

I have 3 divs that belong to the stackContainer class: .stackContainer { position: relative; } Within these divs, I want multiple elements stacked on top of each other. To achieve this, I use the following code: .stackItem { position: absolute; ...

How to Duplicate a Select Box Option in MySQL without Copying the Entire Field (Duplicate Only One Option)

I am in the process of setting up a database for an upload system, specifically using a select box to restrict the number of categories added to the database. <select name="category"> <?php $conn = mysqli_connect("localhost", "blah", "blah") or d ...

Issue with Angular: Mobile view toggle button in the navbar is unresponsive

While the dropdowns are functioning correctly in web mode, the navbar toggle isn't working as expected in small screens or mobile mode. I've been trying to figure out the issue by referring to code from CodePen that I am learning from. Despite i ...

What causes the incompatibility between Bootstrap responsive tables and Angular's 'dir-paginate'?

Why is the bootstrap responsive table not functioning properly with dir-paginate? I successfully created a responsive grid HTML table using bootstrap with static data, but when my angular developer colleague incorporated 'dir-paginate' to fetch d ...

Error message: Injector Error: R3InjectorError(Standalone[_AppComponent])[_WebService -> _WebService -> _WebService] occurred

Being a student, I must apologize in advance for any mistakes in terminology or gaps in my understanding. I am currently developing an Angular front-end to communicate with my backend API. However, I keep encountering the following error in the web page c ...

Getting the dimensions of an image using a path in JavaScript

I am trying to display a div with an image, its name, size, and download link using jQuery. Here is the code I have created: var image = 'image/example.png' $('#download').attr("href", result2); $('.image').attr("src", re ...

What is the best way to ensure that an input field and a button stretch across the entire row in a Bootstrap form?

I need assistance with aligning the Post button to the right and having the text field for tags occupy the entire left section of the row within a Bootstrap 3 form. The form markup is shown below: https://i.sstatic.net/401RU.png Below is the complete cod ...

Tips for making a background image responsive using ng-style in AngularJS

Can anyone assist me in fixing the gap space issue in a responsive view with an attached jpg background image? Follow this link for more details: enter image description here ...

Iterating over an array and displaying elements on the webpage

Struggling to access an array and loop through it, but only able to print out one element instead of all. Need a hint on how to solve this issue. See my code below: let toppingsCount; const burger = document.createElement('div'); const toppingsD ...

Problem encountered when attempting to set and retain default values in a PHP select box

<form name="search" method="post" > Seach for: <input type="text" name="find" value="<?php echo (isset($_POST['find']) ? $_POST['find'] : ''); ?>" /> in <Select NAME="field"> <Option VALUE="catego ...

Creating a CSS grid layout with dual columns to dynamically adjust and accommodate two items in each row

I am attempting to create this layout using CSS grid: https://i.sstatic.net/Ktbnm.png The goal is to have an input and a textarea. The textarea should be of the size of 2 inputs. If there is already a textarea in the previous column, the next column shou ...

Parent: Using Flexbox vs Child: Choosing between inline-block or inline elements (Advantages of utilizing CSS3 flexbox?)

I've been exploring the capabilities of CSS3's new "display: flex" property and trying to determine its advantages. So far, I haven't discovered any significant benefits beyond creating a virtual horizontal line within each flex box containe ...

Tips for adjusting the height of a jQuery UI widget control through CSS

I have implemented a jquery widget on my asp.net webforms and am trying to adjust the height of the select control from the default 22px to 33px. I noticed in Google developer that the height is originally set like this: The current height setting is loca ...

Uninterrupted jQuery AJAX calls

I have a scenario where I need to periodically update an image on my view using ajax every 10 seconds. Any suggestions on how I can achieve this? Appreciate the help. ...

I'm curious if there is a method to validate HTML elements within AngularJS. You can check out my app on Plunker [here](https://jsfiddle.net/4jttdczt/)

I'm a newcomer to angularjs and I am attempting to test HTML elements, but my tests are failing. Specifically, I would like to test the value or text contained within an HTML element. Can anyone provide guidance on how I can achieve this? Below is my ...

Tips for creating equal height columns in Bootstrap 4

Working with Bootstrap 4 Beta in an attempt to create two columns that maintain full height regardless of screen size. The code below functions perfectly, ensuring both columns maintain full height across all devices. However, upon inserting the bootstra ...