My Desired Text Alignment:
I want the text to be centered horizontally at the top of the input. Words should break after hitting the internal padding, similar to how document creation software like Google Docs works with center alignment.
Current Alignment Issue:
Currently, the text is centered in the input box, instead of being horizontally centered at the top. As I continue typing, the text extends to the right without breaking.
Simple HTML Example:
<div class="text-contain">
<input type="text" class="textArea"
value="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed
do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi
ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum."/>
</div>
CSS Styling:
.textArea {
text-align: center;
display: block;
vertical-align: text-top;
word-break: break-word;
white-space: nowrap;
margin-top: 10px;
min-height: 40vh;
width: 66vw;
}
Check out the codepen
https://codepen.io/anon/pen/Kxyqod
If JavaScript is needed, I'm using React, so a solution in the 'React way' would be appreciated.
If you have a CSS solution, utilizing vw units would be ideal.
I'm also working with Bootstrap 4, so any insights related to that would be helpful.
I've searched for an answer to this specific issue but haven't found anything addressing how to align input text like a centered word document with word breaks on internal padding.
If any clarifications are required for this question, please let me know as I'm new to asking questions here.